MyBook World Edition acting as a NFS server
I feel that MyBook Unix users are missing one feature like me: NFS server. It would be nice
to be able to mount MyBook share using native Unix "sharing", nfs. Good news is that it's possible.
Even better is that you don't have to compile anything, everything is already pre-installed on MyBook.
Startup script
First of all you will need nfs startup script, I call it /etc/init.d/nfsd.sh
:
#!/bin/sh
modprobe sunrpc
modprobe lockd
modprobe nfs_acl
modprobe exportfs
modprobe nfsd
sleep 2
portmap
sleep 2
/usr/sbin/rpc.mountd 2>/var/log/nfsdlog
/usr/sbin/rpc.nfsd 5 2>/var/log/nfsdlog
/usr/sbin/exportfs -ra 2>/var/log/nfsdlog
Don't forget to chmod 755 the script!
Running the nfsd.sh script during boot process
The easiest way is to run the script from /etc/inittab, add the bold line:
# Mount the USB filesystem
::sysinit:/bin/mount -t usbfs usbfs /proc/bus/usb
# Run any rc scripts
::sysinit:/etc/init.d/rcS
::sysinit:/etc/init.d/nfsd.sh
# Set up a couple of getty's
#tty1::respawn:/sbin/getty 38400 tty1
#tty2::respawn:/sbin/getty 38400 tty2
Preparing exports
NFS server requires to have share information in /etc/exports, I have the following line in this file:
/shares/internal/ 192.168.1.0/255.255.255.0(rw,sync,all_squash,anonuid=33)
This means that all hosts on network 192.168.1.0/24 can mount this share in read-write mode in sync access mode
and all accessess are done using uid 33 (www-data, used for windows sharing). For more information
look at exports manual page.
Testing ....
Now reboot your MyBook using reboot command. Then you can
try to mount the "/shares/internal" folder from your Unix box. On Linux, you have to:
- Insmod sunrpc.ko, nfs_acl.ko, lockd.ko, nfs.ko
- Run portmap and rpc.mountd
- mount mybook_ip:/shares/internal /mnt -o rw