Saturday, April 4, 2009

Installing NFS file sharing


The Alix computer (the MPD server) needs to be able to access the music files (over the network) which are stored on the desktop computer (in the music library).

So we need to install NFS file sharing between the two machines where the desktop computer will be the NFS file server and the Alix computer the NFS file client.

remember : in my example the desktop computer's IP address is 192.168.1.20 and the Alix's 192.168.1.30

On the desktop computer, install the NFS server packages :
  • write "aptitude install nfs-kernel-server nfs-common portmap" and press ENTER
On the Alix computer, install the NFS client packages :
  • write "ssh -2 p 22 root@192.168.1.30" and press ENTER
  • enter the root password
  • write "remountrw" and press ENTER
  • write "apt-get install nfs-common portmap" and press ENTER
  • write "remountro" and press ENTER
  • write "exit" and press ENTER (= leave the Alix computer)
Setting up the NFS server :
For setting up an NFS server, you need to edit /etc/exports.

In this example we will share the following folder on the server with the client 192.168.1.30 : "/home/your_username/music"

remember : "your_username" = same username as on the desktop computer

Create the /music folder (if it doesn't exist yet) :
  • write "cd /home/your_username" and press ENTER
  • write "mkdir music" and press ENTER
Then open the file /etc/exports with your favorite text editor :
(I use "jed". If you don't have jed on the desktop computer, install it with "aptitude install jed")
  • write "jed /etc/exports" and press ENTER
  • add the following text :
/home/your_username/music 192.168.1.30(rw,no_subtree_check,sync)

Save the modification and exit the editor :
  • press "Ctrl+x+s" and then press "Ctrl+x+c"
To (re-)start the NFS server :
  • write "/etc/init.d/nfs-kernel-server restart" and press ENTER

Setting up the NFS client :
We want the Alix computer to mount the NFS share every time it starts up. So we have to modify the /etc/fstab configuration file.
  • write "ssh -2 -p 22 root@192.168.1.30" and press ENTER
  • enter the root password of the Alix
  • write "remountrw" and press ENTER
  • write "jed /etc/fstab" and press ENTER
  • add the following line at the end (and after that press ENTER to have an empty line after this line) :
192.168.1.20:/home/your_username/music /mnt/nfs nfs rw 0 0
  • press Ctrl+x+s
  • press Ctrl+x+c
  • move to the /mnt folder and write "mkdir nfs" and press ENTER
  • write "mount -a" and press ENTER
  • write "remountro" and press ENTER
  • write "exit" and press ENTER (you will leave the Alix computer)