Maintaining the Raspberry Pi Squeezebox server (aka Logitech Media Server)

This article describes how to maintain a Squeezebox server (or Logitech Media Server). All software used for this project is free and open source.

I wrote earlier about the Logitech Media Server (LMS), open source software that I’ve used to turn a Raspberry Pi into a music server for my Squeezebox devices. I’m using my Raspberry Pi based Logitech Media Server a couple of months and I’ve grown very fond of it. What started as an experiment now has become a device I’m starting to rely on. I guess that eventually I have to replace the USB-HDD that I connected to the Raspberry Pi with a better one. In the meantime however I do need to maintain the LMS. In this blogpost I’ll explain how I add and remove music files from the LMS and create a simple backup of your music files. Finally I provide a tip to debug problems with the Logitech Media Server. All software that I used for this project is free and open source.

Adding, changing and deleting music files

When I buy a new CD I want to add it to my LMS. All the ripping is done on my Thinkpad T40 laptop using Asunder, a low resource ripper for Linux. In the beginning I unmounted the USB hard disk from the LMS, removed it and connected it to the laptop and copied the albums. For new albums this proved to be be a clumsy method and I quickly found myself looking for an alternative.

I decided to use FTP to transfer files over the network to the Raspberry Pi. FTP is a network protocol to transfer files between a client and a server. The software that I’m using is either FileZilla or gFTP. They have basically the same functionality but gFTP is not available for Windows while FileZilla is available for GNU/Linux, OSX and Windows. Working with both is easy enough the only problem that I had was to set the ownership for the USB hard disk on the Raspberry Pi. Only root was able to write to the disk. The reason is a bit technical and maybe confusing but I had used the Windows FAT filesystem for the USB hard disk and when I mounted it on my Linux laptop (Puppy Linux distro), ownership of all files was changed by Puppy Linux to root. At this point it was impossible to change ownership and permissions with chmod and chown from the media server. To solve this problem I had to unmount and mount the USB hard disk using the following general command:

mount device mount-point -o uid=foo -o gid=foo

or in my specific case

mount /dev/sda1 /media/usb-drive -o uid=pi -o gid=pi

This command sets the ownership of all files on the USB hard disk to pi instead of root enabling me to use FileZilla and gFTP to copy files from a remote PC to the Raspberry Pi.

Adding Podcasts to the server

Podcasts can be easily added to the Logitech Media Server and there is no need to subscribe to a service. First the Podcasts app must be added to myApps on the Squeezebox player or players. Next to add podcasts to the list a plugin needs to be installed. To do this open the web interface in your browser and type:

<your_Raspberry_Pi_ip_address:9000> (in my case 192.168.178.69:9000)

Choose Settings at the bottom right of the web browser and then choose the Plugins tab. Now enable the Podcasts (v2.0) plugin and reboot the Raspberry Pi for the changes to take effect. The Podcasts plugin is now active and can be entered through a new tab in the Settings menu. In this tab new feeds can be entered that will immediatly be available on the Squeezebox players. To find a certain feed look for the rss feed of your favorite podcast and copy the link into ‘add a new feed’ in the podcast tab of the Settings menu mentioned above (e.g. http://feed.thisamericanlife.org/talpodcast for This American Life).

Creating a backup of the music collection

I invested a lot of time in ripping my CD collection so it would be a shame if I lost my music files due to a hard disk crash. I therefore use a very simple backup method, largely copied from the Raspberrypi.org website to ensure that my files are safe. First make sure that there’s enough harddisk space available with df -h. Next do:

tar -cvf backup.tar.gz ~/media/usb-drive

This creates a file ‘backup.tar.gz’ that contains files in /media/usb-drive, the mounting point of my USB drive and places it in the same map. Next I use (again) Filezilla to move the backup file to my desktop computer. Alternatively the ripped files on the PC they were ripped on can serve as a backup.

Debug problems with the Logitech Media Server

I didn’t encounter much problems with the LMS but if you do take a look into the log file of the server. This can be done opening a terminal on your PC and login into the Rasperry Pi with:

ssh pi@<your_network_ip_address_of_the_server>
cat /var/log/squeezeboxserver/server.log

The sudo ssh command prompts for the password of the Raspberry Pi. Now look for anything suspicious in the log, copy it and do an internet search with your preferred search engine. Chances are someone already encountered the same problem.

Creating a Raspberry Pi Squeezebox server

Create your own Squeezebox server (or Logitech Media Server) with a Raspberry Pi and a HDD in five steps.

If you, like me, own one or more Squeezebox players you can either choose between the service mysqueezebox.com, that streams music from the internet, or set up the Squeezebox server on your own network. The Squeezebox server software (aka Logitech Media Software) being free and open source software guarantees that you’ll take control of your Squeezebox players and the music that you’re streaming.

There many hardware options for the Squeezebox server software (or Logitech Media Server) but I decided to use the Raspberry Pi 2 that I had lying around because of it’s small footprint and massive support for the Pi. Within a couple of hours I had the Logitech Squeezebox Server up an running with my music playing.

Below I’ll show how to set up the Logitech Squeezebox Server on a Raspberry Pi in five steps. I got some important steps from the Variax Firmation website but I tested everything successfully.

Raspberry Pi 2 with a USB-harddrive connected to my network with a (yellow) ethernet cable.
Raspberry Pi 2 with a USB-harddrive connected to my network with a (yellow) ethernet cable.

Step 1: Ripping CD’s and writing them on an HDD (choosing an audio format)

Before setting up a server rip the CD’s and write them to a HDD. For this project I used a small usb-harddrive that was also lying around. I formatted the HDD as FAT32. Next I collected all my music CD’s and ripped them. As ripping software I used the Asunder software on my Linux system but I guess that they’re good alternatives (fre:ac appears to be an free and open source alternative that is also available for OSX and Windows). As audio format I choose mp3. If I buy a larger drive I’ll probably move to flac.

Step 2: Installing Raspbian Lite

Next I installed Raspbian Lite (currently Raspbian Buster Lite) on the Raspberry Pi 2 by first downloading the image and writing the image to the micro SD card using these instructions for OSX (or these instructions for Windows and Linux).  I chose the lite version of Raspbian to make the server as lightweight as possible. I had no problems booting the Raspberry Pi and connecting it to my network using Ethernet. To avoid potential problems connect the Pi to a monitor with an HDMI cable and make sure that it boots properly.

Step 3: Mount the HDD on the Raspberry Pi

Now with Raspbian Lite installed I mounted the HDD that we prepared in step 1. For this first connect the HDD to the Raspberry Pi (in my case I connected the HDD through a USB port of the Raspberry Pi), login remotely and retrieve the name of the drive. To login remotely we need another computer (Windows, Linux or OSX). Open a terminal (or Putty in case of Windows) and type:

sudo ssh pi@Raspberry_Pi_ip_address (in my case 192.168.178.69)

The default password is raspberry. Then type:

sudo fdisk -l 

Then look for the HDD that is just connected. This was /dev/sda1 in my case (but this may differ in yours). To make the files on the HDD accessible to the Raspberry Pi we need mount the drive. But before that we need to make a mounting point (in this example at ~/media/usb-drive).

sudo mkdir /media/usb-drive 

and mount

 sudo mount /dev/sda1 /media/usb-drive

You should hear some HDD activity. Now type:

cd /media/usb-drive ls -l

and a list of your music should be visible.
To unmount the HDD do:

sudo umount /media/usb-drive
 The list of folders with albums that I ripped. In this stage I only ripped a few albums to test the system.
The list of folders with albums that I ripped. In this stage I only ripped a few albums to test the system (click to enlarge).

Step 4: Installing Logitech Media Center on the Raspberry Pi

First we need to install a library to play audio files. Since you want mp3 only do:

sudo apt-get install -y libsox-fmt-all

This installs SoX, a command line utility that, among other things, plays various types of audio files. If you want to add flac support you’ll probably need to do this

sudo apt-get install -y libsox-fmt-all libflac-dev

Now with the audio libraries in place the Logitech Media Software can be downloaded. We want the latest version which is 7.9.2.

sudo wget -O logitechmediaserver_all.deb $(wget -q -O - "http://www.mysqueezebox.com/update/?version=7.9.2&revision=1&geturl=1&os=deb")

Now install the server software with:

sudo dpkg -i logitechmediaserver_all.deb

With all the software installed we’re ready to go.

Step 5: Working with Logitech Media Center

To enter the web interface of the Logitech Media Center on the Pi we need a computer and a browser. In the browser url we type:

<your_Raspberry_Pi_ip_address:9000> (in my case 192.168.178.69:9000)

The Logitech Media Center is started for the first time and a script is started to set it up. Important is that the mounting point of the HDD (in my case /media/usb-drive) is entered. This way the Media Center is able to retrieve all the music files. This is done in the web interface by entering the path of the mounting point under Media Settings under Media Folders.

The Media Settings page of the web interface. Enter the path of the mounting point under Media Folders.
The Media Settings page of the web interface. Enter the path of the mounting point under Media Folders (click to enlarge).

The Logitech Media Server is now ready and every time the Raspberry Pi boots the Logitech Media Server is automatically started however the HDD is not automatically mounted so we need to change that. This is done by editing (with nano) the fstab system configuration file that can be found at /etc/fstab

sudo nano fstab

and add the following line

/dev/sda1 /media/usb-drive vfat& defaults 0

Save the file and exit nano. Reboot the Raspberry Pi. Now the installation is complete. The music can be played from the web interface (see above), with the remote controls that come with the Squeezebox devices or with a free app for Android. The Squeezebox Radio also has controls on the device to play the music. So, plenty of options.

Webinterface of the Logitech Media Server (click to enlarge).

Whats next

In a future blog entry I’ll explain how to maintain the Logitech Media Server e.g how to add music to the server remotely.