To turn the MBWE into a NFS server, follow the following steps:
//Please note, NFS is no longer included on newer firmware versions 2.00.15+. You can recover NFS from the backup images in the rescue thread. Appropriate exec rights should be given to files. //
Installation
In /etc/init.d/, create the following script (taken from WD Online Forum) to start/stop NFS services:
#!/bin/sh
#
# Start NFS
#
start() {
echo "Starting NFS"
/sbin/modprobe nfsd
sleep 2
start-stop-daemon --start --exec /sbin/portmap
start-stop-daemon --start --exec /usr/sbin/rpc.mountd
start-stop-daemon --start --exec /usr/sbin/rpc.nfsd
start-stop-daemon --start --exec /usr/sbin/rpc.statd
start-stop-daemon --start --exec /usr/sbin/rpc.lockd
start-stop-daemon --start --exec /usr/sbin/rpc.rquotad
/usr/sbin/exportfs -a # explicit exportfs is required!
}
stop() {
echo "Stopping NFS"
start-stop-daemon --stop --exec /usr/sbin/rpc.rquotad
start-stop-daemon --stop --exec /usr/sbin/rpc.lockd
start-stop-daemon --stop --exec /usr/sbin/rpc.statd
start-stop-daemon --stop --exec /usr/sbin/rpc.nfsd
start-stop-daemon --stop --exec /usr/sbin/rpc.mountd
start-stop-daemon --stop --exec /sbin/portmap
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
cleanup)
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
A good name for the script would be nfs.sh. Don't forget to make it executable with a chmod 755 /etc/init.d/nfs.sh .
The NFS portmap version installed in the mybook requires that user "rpc" and group "rpc" exists, but you have to create it yourself. Run the following commands:
[root@nas init.d]# addgroup rpc
[root@nas init.d]# adduser -h /var/lib/nfs -g "RPC Service User" -s /sbin/nologin -G rpc -D rpc
If you want to verify the user/group was created, examine /etc/passwd and /etc/group:
$ grep rpc /etc/passwd
rpc:x:1003:1003:RPC Service User:/var/lib/nfs:/sbin/nologin
$ grep rpc /etc/group
rpc:x:1003:
Choosing Shares
Finally, you'll need to create/edit the /etc/exports file to contain something like:
/shares/internal/PUBLIC 192.168.0.0/255.255.0.0(rw,sync,insecure)
The above subnet should work for most people, but change it to match if necessary. Note that there is no space between the subnet address and the opening parenthesis. Also make sure the name resolution of the client in /etc/hosts is correct. If you edit the /etc/exports file whilst NFS service is running, you can apply changes to the live sever by running exportfs -a (as root).
Parameter insecure seems to be necessary to fix the following message (known to be a problem for mac clients):
Feb 14 00:19:58 nas user.warn kernel: nfsd: request from insecure port (192.168.1.84:49614)!
Feb 14 00:21:17 nas user.notice syslog: authenticated mount request from cslaptop.config:1016 for /shares/internal/PUBLIC (/shares/internal/PUBLIC)
Note: Using just the above /etc/exports entry may mean you can only mount the file system remotely in read-only mode (or, at least, do not have sufficient permissions to write to the file system). In order to tell the World Book to treat all remote changes as coming from the share owner you can use the following instead:
/shares/internal/PUBLIC 192.168.0.0/255.255.0.0(rw,sync,insecure,all_squash,anonuid=33,anongid=33)
The all_squash option tells the World Book to map all user ids to the anon ids given in the next options. The id 33 is the owner of the share on my system, you can check this is the case on your world book with the commands:
# ls -ld /shares/internal/PUBLIC/
drwxrwxr-x 23 root www-data 4096 Oct 22 10:11 /shares/internal/PUBLIC/
# grep www-data /etc/passwd /etc/group
/etc/passwd:www-data:x:33:33:www-data:/var/www:/bin/sh
/etc/group:www-data:x:33:
Note that /etc/hosts.allow and /etc/hosts.deny do not exist in 2.00.15+ so they will need to be updated as well:
/etc/hosts.allow
ALL: ALL@127.0.0.1 : ALLOW
ALL: ALL@192.168.0.0/255.255.0.0 : ALLOW
/etc/hosts.deny
ALL: ALL@ALL
Also note, that the /etc/exports and /etc/hosts.allow entries shown assume you are on a network with addresses starting 198.168. - you can check this on the World Book as follows:
# ifconfig eth0
eth0 Link encap:Ethernet HWaddr FF:90:FF:25:FF:FF
inet addr:10.0.0.237 Bcast:10.0.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7704010 errors:0 dropped:0 overruns:0 frame:0
TX packets:2560435 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1422255077 (1.3 GiB) TX bytes:2264850072 (2.1 GiB)
Interrupt:21 Base address:0x1000
The line beginning inet addr tells you the address of the World Book. As mine starts 10.0 I would use 10.0.0.0/255.255.0.0 in the exports and hosts.allow files instead.
Start the service and you will be in business!
[root@nas init.d]# /etc/init.d/nfs.sh start
Starting NFS
[root@nas init.d]#
Autostarting NFS
To have nfs.sh autostart, edit the file /etc/init.d/post_network_start.sh. Be particularly careful, as if you mess up this file the boot scripts may hang. I would advise starting nfs.sh below SSHD and commenting out mionet.sh if you do not use the service.
#!/bin/sh
#
<snip>
SCRIPTS_PATH=/etc/init.d
STATUS_FILES_PATH=/var/run
POST_NETWORK_STARTED_FILE=$STATUS_FILES_PATH/post_network_started
start() {
if [ ! -e "$POST_NETWORK_STARTED_FILE" ]
then
$SCRIPTS_PATH/crond.sh start
# $SCRIPTS_PATH/mionet.sh start
$SCRIPTS_PATH/nfs.sh start # Add NFS service!!!
touch $POST_NETWORK_STARTED_FILE
fi
}
stop() {
if [ -e "$POST_NETWORK_STARTED_FILE" ]
then
# $SCRIPTS_PATH/mionet.sh stop
$SCRIPTS_PATH/crond.sh stop
$SCRIPTS_PATH/nfs.sh stop # Add NFS services!!!
rm $POST_NETWORK_STARTED_FILE
fi
}
restart() {
stop
start
}
cleanup() {
rm -f $POST_NETWORK_STARTED_FILE
$SCRIPTS_PATH/nfs.sh cleanup # Add NFS services !!!
$SCRIPTS_PATH/crond.sh cleanup
# $SCRIPTS_PATH/mionet.sh cleanup
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
cleanup)
cleanup
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
Now also read http://wiki.linux-nfs.org/wiki/index.php/NFS_Howto_Optimization to max out your nfs.
See this thread for more info: http://mybookworld.wikidot.com/forum/t-28307/nfs