Raspberry Pi vs. Music via NFS

Every now & again, streaming music from distant servers fails, for no reason I can determine. In that situation, it would be nice to have a local source and, as mplayer works just fine when aimed at an MP3 file, I tried to set up a USB stick on the ASUS router.

That requires getting their version of SAMBA working with the Raspbian Lite installed on the streaming players. After screwing around for far too long, I finally admitted defeat, popped the USB stick into the Raspberry Pi running the APRS iGate in the attic stairwell, and configured it as an NFS server.

To slightly complicate the discussion, there’s also a file server in the basement which turns itself off after its nightly backup. The local music files must be available when it’s off, so the always-up iGate machine gets the job.

On the NFS server:

Install rpcbind and nfs-common, both of which should already be included in stock Raspbian Lite, and nfs-kernel-server, which isn’t. There were problems with earlier Raspbian versions involving the startup order which should be history by now; this post may remind me what’s needed in the event the iGate NFS server wakes up dead after the next power blink.

Set up /etc/exports to share the mount point:

/mnt/music	*(ro,async,insecure,no_subtree_check)
# blank line so you can see the underscores in the previous one

Plug in the USB stick, mount, copy various music directories from the file server’s pile o’ music to the stick’s root directory.

Create a playlist from the directory entries and maybe edit it a bit:

ls -1 /mnt/part/The_Music_Directory > playlist.tmp
sed 's/this/that/' < playlist.tmp > playlist.txt
rm playlist.tmp

Tuck the playlist into the Playlists directory on the basement file server, from whence the streamer’s /etc/rc.local will copy the file to its local directory during the next boot.

On every streamer, create the /mnt/music mountpoint and edit /etc/rc.local to mount the directory:

<<< snippage >>>
mount -v -o ro $nfs_music:/mnt/music /mnt/music
# blank line so you can see the underscores in the previous one 

In the Python streaming program on the file server, associate the new “station” with a button:

         'KEY_KP8'   : ['Newname',False,['mplayer','-shuffle','-playlist','/home/pi/Playlists/playlist.txt']],

The startup script also fetches the latest copy of the Python program whenever the file server is up, so the new version should Just Work.

I set the numeric keypad button associated with that program as the fallback in case of stream failures, so when the Interwebs go down, we still have music. Life is good …



  1. Leave a comment

Spam comments vanish. Comment moderation may cause a delay.

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s