NFS (unfsd) on Optware - Successful install

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Goto page 1, 2  Next
Author Message
cmcgrath5035
DD-WRT Novice


Joined: 30 Sep 2007
Posts: 26

PostPosted: Sun Jan 02, 2011 1:23    Post subject: NFS (unfsd) on Optware - Successful install Reply with quote
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


/mnt/Share-Export       192.168.10.0/255.255.255.0(rw,sync,no_subtree_check,no_root_squash)

4. reboot or manually start portmap and unfsd
Code:
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
Sponsor
Masterman
DD-WRT Guru


Joined: 24 Aug 2009
Posts: 2070
Location: South Florida

PostPosted: Sun Jan 02, 2011 2:14    Post subject: Reply with quote
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
lamelogin
DD-WRT Novice


Joined: 18 Sep 2010
Posts: 25

PostPosted: Sun Jan 02, 2011 3:40    Post subject: Reply with quote
Are the start scripts going to be modified to work with "service" properly? Should this be mentioned in the Wiki?

root@tivorouter:/opt/etc/init.d# egrep NAME S55portmap S56unfsd
S55portmap:NAME=portmap
S56unfsd:NAME=nfsd
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Jan 02, 2011 10:43    Post subject: Reply with quote
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

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
cmcgrath5035
DD-WRT Novice


Joined: 30 Sep 2007
Posts: 26

PostPosted: Sun Jan 02, 2011 12:00    Post subject: Reply with quote
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?

Thanks, OTRW is just superb
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Jan 02, 2011 12:17    Post subject: Reply with quote
Code:
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

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
bkmo
DD-WRT User


Joined: 18 Oct 2007
Posts: 385
Location: Grecia, Costa Rica

PostPosted: Sun Jan 02, 2011 16:11    Post subject: Reply with quote
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.


Thanks, the scripts work well. I have one issue though, I get this at stopping and reboot also:

root@DD-WRT:~# service unfsd stop
S56unfsd: Stopping unfsd:
unfsd: no process found

but the service does stop. I also had permission denied issues running as www-data.
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Jan 02, 2011 16:12    Post subject: Reply with quote
How's testing?
_________________
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

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
bkmo
DD-WRT User


Joined: 18 Oct 2007
Posts: 385
Location: Grecia, Costa Rica

PostPosted: Sun Jan 02, 2011 16:21    Post subject: Reply with quote
frater wrote:
How's testing?


See above ^ (above your post)

NFS is much faster than Samba, and is perfect in a pure Linux environment. Nice job OP and Frater.
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Jan 02, 2011 17:38    Post subject: Reply with quote
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'

I corrected it..:
Code:
wget -O /opt/etc/init.d/S54portmap http://wd.mirmana.com/S55portmap
wget -O /opt/etc/init.d/S56unfsd http://wd.mirmana.com/S56unfsd
ln -s S55portmap /opt/etc/init.d/K45portmap
ln -s S56unfsd   /opt/etc/init.d/K44unfsd


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

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
sagar777
DD-WRT Novice


Joined: 02 Jan 2011
Posts: 17

PostPosted: Sun Jan 02, 2011 23:28    Post subject: Reply with quote
I just tested NFS on my ASUS RT-N16 with Ubuntu by installing using following commands:

wget -O ~/prep http://wd.mirmana.com/prep_optware
sh ~/prep

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)
---
bkmo
DD-WRT User


Joined: 18 Oct 2007
Posts: 385
Location: Grecia, Costa Rica

PostPosted: Tue Jan 04, 2011 0:14    Post subject: Reply with quote
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.
hching
DD-WRT Novice


Joined: 18 Jul 2009
Posts: 39

PostPosted: Tue Jan 04, 2011 1:57    Post subject: Reply with quote
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.
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Tue Jan 04, 2011 7:18    Post subject: Reply with quote
bkmo wrote:
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.
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).

This is the result:

Code:
root@WDS:~# netstat -lnp | grep unfsd
tcp        0      0 0.0.0.0:2049            0.0.0.0:*               LISTEN      18457/unfsd
udp        0      0 0.0.0.0:2049            0.0.0.0:*                           18457/unfsd
root@WDS:~# service unfsd stop
S56unfsd: Stopping unfsd:
root@WDS:~# service unfsd start
Start service "unfsd" (/opt/etc/init.d/S56unfsd)
service: Start service: "unfsd" (/opt/etc/init.d/S56unfsd)
S56unfsd: Starting unfsd:
root@WDS:~# netstat -lnp | grep unfsd
tcp        0      0 192.168.10.10:2049      0.0.0.0:*               LISTEN      20269/unfsd
udp        0      0 192.168.10.10:2049      0.0.0.0:*                           20269/unfsd

_________________
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

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Wed Jan 05, 2011 19:59    Post subject: Reply with quote
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)


cat /opt/etc/init.d/S56unfsd
Code:
#!/bin/sh
prefix=/opt
export PATH=${prefix}/bin:${prefix}/sbin:${prefix}/usr/sbin:/sbin:/bin:/usr/sbin:/usr/bin
export LD_LIBRARY_PATH=${prefix}/lib:${LD_LIBRARY_PATH}

NAME=unfsd
PROC=unfsd
BIN=${prefix}/sbin/unfsd
EXPORTS=/opt/etc/exports
AS_USER=www-data
SCRIPT=`basename ${0}`
lan_ipaddr=`nvram get lan_ipaddr`

if [ -z "$1" ] ; then
    case `echo "$0" | sed 's:^.*/\(.*\):\1:g'` in
        S??*) rc="start" ;;
        K??*) rc="stop" ;;
        *) rc="usage" ;;
    esac
else
    rc="$1"
fi

grep -q nobody     /etc/group  || echo "nobody:x:99:" >> /etc/group
grep -q ${AS_USER} /etc/group  || echo "${AS_USER}:x:33:" >> /etc/group
grep -q nobody     /etc/passwd || echo "nobody:x:99:99:nobody:/var:/bin/false" >> /etc/passwd
grep -q ${AS_USER} /etc/passwd || echo "${AS_USER}:x:33:33:${AS_USER}:/mnt:/bin/sh" >> /etc/passwd

# 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

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum