Posted: Sun Jan 02, 2011 1:23 Post subject: NFS (unfsd) on Optware - Successful install
Following several forum items and suggestions from Frater, I successfully implemented an NFS service on my RT-16N router.
I am running DD-WRT v24-sp2 (12/24/10) big - build 15962 and Optware Done the Right Way.
I have an attached USB HDD for /opt and a big share that installs on /mnt.
1. Install portmap with ipkg-opt install portmap
2. Install unfs3 with ipkg-opt install unfs3
Both download the executable and a setup script installed in /opt/etc/init.d
unfs3 needs the libs in /opt/lib to run.
Frater recommends we avoid a global change to LD_LIBRARY_PATH, so I changed the startup file as follows
Code:
/opt/etc/init.d# cat S56unfsd
#!/bin/sh
if [ -n "`pidof unfsd`" ] ; then
killall unfsd 2>/dev/null
fi
sleep 2
#cjm /opt/sbin/unfsd
#cjm Make sure uClib is used and specify path for 'exports' file
LD_LIBRARY_PATH=/opt/lib:${LD_LIBRARY_PATH}
/opt/sbin/unfsd -e /opt/etc/exports
#cjm
3. create an exports file, such as
Code:
root@DD-WRT-Cape-RT16N:/opt/etc# cat exports
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
#cjm sets up exports 1 January 2011
sh /opt/etc/init.d/S55portmap
sh /opt/etc/init.d/S56unfsd
5. check to see they are running with ps -A
6. From another *nix on your LAN,execute
Code:
showmount -e 192.168.10.1
results-->
Export list for 192.168.10.1:
/mnt/Share-Export 192.168.10.0/255.255.255.0
Since many seem to ask, I ran a quick comparison of file copy from My SuSE machine to this shared folder, which is accessable both with Samba3 and unfsd. The network is a GigE(wired).
I copies a 1GB file from SuSE to DD-WRT/Optware
Samba3 - 4.7 MB/s avg
unfsd - 6.1Mb/s avg
The combination of the RT-16N/DD-WRT/OptwareDoneRight is awesome
Joined: 24 Aug 2009 Posts: 2070 Location: South Florida
Posted: Sun Jan 02, 2011 2:14 Post subject:
Awesome job! Should be added to the Wiki. I will do it after I test it out.. _________________ Optware, the Right Way
Asus RT-AC68U
Asus RT-N66U
Asus RT-N10
Asus RT-N12
Asus RT-N16 x5
Asus WL520gU
Engenious ECB350
Linksys WRT600Nv1.1
Linksys WRT610Nv1
Linksys E2000
Netgear WNDR3300
SonicWall NSA220W
SonicWall TZ215W
SonicWall TZ205W
SonicWall TZ105W
I have added modified S55portmap and S56unfsd to OTRW
Feel free to test
unfsd will be started as a less-privileged user (www-data) to enhance security. Although that's not really necessary. _________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
Frater, your action brings up two questions:
1. What is the best method to keep OTRW up-to-date with modifications you make? Perform a wget of your scripts again? I assume that
Code:
ipkg-opt update
ipkg-opt upgrade
would maintain the packages themselves. If this is already on the forum, a link would be appreciated.
2. If for some reason I needed to download an update of the DD-WRT Firmware, what is the recommended procedure for handling OTRW?
wget -O ~/prep http://wd.mirmana.com/prep_optware
sh ~/prep
_________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
You should change owner of /mnt to www-data.www-data if you want to use it with the less-privileged www-data...
Code:
chown -R www-data.www-data /mnt
I intended to pipe error messages to /dev/null, but had to use ">dev/null 2>&1" instead of "2>&1 >/dev/null"
The last 'killall' should have been a 'killall -9'
You can use the S55portmap as a template for future packages that have such a super simple startup script... _________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
works like a charm, thanks!! _________________ ASUS RT-N16.
DD-WRT v24-sp2 (12/19/10) mega - build 15943M NEWD-2 K2.6 Eko.
Optware the Right way.
USB1=8GB Transcend Flash
USB2=2TB HDD (Not working yet)
----
USB1 partitioning:
* /opt 2048 megabytes
* swap 256 megabytes
* /jffs 1024 megabytes
* data remainder of the disk (/mnt 4.4GB)
---
Joined: 18 Oct 2007 Posts: 385 Location: Grecia, Costa Rica
Posted: Tue Jan 04, 2011 0:14 Post subject:
frater wrote:
I have added modified S55portmap and S56unfsd to OTRW
Feel free to test
unfsd will be started as a less-privileged user (www-data) to enhance security. Although that's not really necessary.
I was not happy with permissions issues when running with www-data so I looked for a better option. I found that if you execute unfsd as root with the -s option then the client has no permissions issues.
Code:
/opt/sbin/unfsd -s -e /opt/etc/exports
The client has access to the mounts as if they were the user that started unfsd, in this case root. This way you don't need to chown any permissions, and in my case gives me root access to /opt also.
Great job & thanks! I looked into this a while back and have a slightly different but related requirement. Can I run NFS as a client rather than a server with "optware the right way"?
I want to do this because I want to dedicate the rt-n16 as the centralized samba machine to take the Samba load off my other linux devices, and using CIFS defeats the purpose because my understanding is that CIFS requires Samba, which uses quite a bit of resources, on the server machines.
I think a router is perfect for this (better than a NSLU2 I had anyway) because it has decent processing power to serve files yet it does not have a build-in crypto accelerator (not one that is enabled anyway), which I use to encrypt all my hard drives.
This and the lack of the "cryptsetup" package in the optware software repository have prevented me from connecting my encrypted hard drives directly to the rt-n16 and running it as an NFS server.
I apologize if I have hijacked the thread and if so, let me know and I will start a new one instead.
Thanks.
ps. I understand that this has not been possible but am just hoping that the findings from this thread with people who are knowledgeable in this may change it.
The client has access to the mounts as if they were the user that started unfsd, in this case root. This way you don't need to chown any permissions, and in my case gives me root access to /opt also.
I need to look at this a bit more to see if it's something I want too.
I did change the script slightly, because I don't want the service to use all interfaces (bind to 0.0.0.0).
_________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
I added some extra output when the option 'status' is used. The manual showed it writes some info to the log, so I decided to show this.
I also noticed the '/opt/etc/exports' the OP proposed and I just copied was not fully accepted by this implementation of unfsd (sync & no_subtree_check). That's why I omitted these options from the downloadable exports file.
I still didn't find any time to investigate if '-s' is a preferred option in this setup.
cat /opt/etc/exports
Code:
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
/mnt 192.168.0.0/255.255.0.0(rw,no_root_squash)
# Start/Stop/Status samba
case "$rc" in
status)
if killall -SIGUSR1 ${PROC} >/dev/null 2>&1 ; then
echo "${NAME} is running"
tail -n5 /var/log/messages | grep -o "${PROC}.*"
else
echo "${NAME} is not running"
fi
;;
start)
if pidof ${PROC} >/dev/null ; then
echo "${NAME} already running"
else
optlog "${SCRIPT}" "Starting ${NAME}:"
sudo -u ${AS_USER} ${BIN} -e ${EXPORTS} -l ${lan_ipaddr}
fi
;;
stop)
if ! pidof ${PROC} >/dev/null ; then
echo "${NAME} is already stopped"
else
optlog "${SCRIPT}" "Stopping ${NAME}:"
n=1
while [ $n -lt 20 ] ; do
killall ${PROC} >/dev/null 2>&1
pidof ${PROC} >/dev/null || break
sleep 1
let n+=1
done
killall -9 ${PROC} >/dev/null 2>&1
fi
;;
restart)
"$0" stop
sleep 1
"$0" start
;;
*)
echo "Usage: $0 (start|stop|restart|status|usage)"
;;
esac
exit 0
_________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge