Accessing Your NFS Music Share At Startup
If you use Amarok (best music player ever) and you have an NFS server that you store all of your music on you’ve probably experienced the pain of starting up Amarok before you mount your share. Now your entire collection is wiped out and you’re going to have to wait for it to rebuild. It’s possible you’ve tried to mount the share at boot using an fstab entry, but you’re on a machine that isn’t always connected to the server and it takes forever to boot up when you aren’t on the network. Here’s your Ubuntu/Kubuntu solution:
To mount an NFS share in Ubuntu you will first need to install the nfs-common package if you haven’t already.
sudo apt-get install nfs-common |
Next we need to make an entry in /etc/fstab using your favorite text editor. Before we do that let’s examine some things that make this solution work well. First we need to worry about rights. Since there’s usually no reason for Amarok to be able to write to the music files it’s best to just mount the share read-only, so we’ll use the ro flag.
Next we’ll use the “soft” flag. By default the share will be mounted as “hard” meaning that if an application (Amarok in our case) tries to access a file through the mounted share and the server is unavailable it will sit and wait for the server to come back online. This can cause issues for us, so we’ll use soft which will report an error to the application.
We will also specify the “intr”, or interrupt, option. This is used mostly with hard mounted shares to allow the application to interrupt the NFS communication and continue on. We’re enabling it here purely for safety’s sake.
Last we’ll specify the read data block size, or “rsize” to it’s usual default of 8192 bytes. If you’re having skips or other network issues you may try setting this to a larger size, just be warned that some network cards and/or drivers may not work well with the larger block sizes. We won’t need to set the write data block size (“wsize”) because we’re mounting the share read-only. So our fstab entry would look something like this:
servername:/path/to/share /local/mount/point nfs ro,soft,intr,rsize=8192 0 0 |
I use this on my laptop which uses a WPA2 wireless connection. In Kubuntu this means my network connection isn’t actually up and able to mount the share until KNetworkManager loads and I type in my password to open my KWallet. Since I tend to leave Amarok open when I reboot this solution works well for me because it keeps Amarok a little more sane for me.