What is this guide for?
With just a few steps, this guide will show you how to transform a Raspberry Pi (a credit card-sized single-board computer) into a music server that can be connected to speakers or your stereo system and play music in almost all formats from a USB stick, a network, or directly from the internet. If you’ve been running your PC or laptop for this purpose until now, a Raspberry Pi is an excellent choice. It’s extremely energy-efficient, silent, and small, requires no dedicated screen or keyboard, so it can perform its duties unobtrusively anywhere. Sure, there are plenty of Bluetooth speakers available nowadays that solve a similar problem. But does your Bluetooth speaker also play internet radio or store your entire music collection and function as a NAS on the side? Probably not.
What you need
- (WiFi) router from your internet service provider
- Raspberry Pi & power supply
- An SD card (or MicroSD if using a Pi 2, at least 2GB)
- Network connection near your stereo system. (Alternatively, the device can be equipped with a WiFi stick so you can place it anywhere)
- USB sound card (recommended)
- USB WiFi adapter (optional)
Recommended and optional hardware
The Raspberry Pi already comes with an on-board sound adapter and the ability to connect speakers or headphones. However, the output quality is quite modest and can be significantly improved by plugging a sound card into one of the free USB ports. The sound card linked above has been tested and works immediately without further setup. Just plug it in and you’re ready to go.
Like the sound card, the linked WiFi adapter has already been tested, works perfectly plug & play, and is very affordable to purchase. However, if you use this option, you’ll have both USB ports occupied and can expand the number of ports with a USB hub if you want to connect external storage. It’s your decision.
The two USB cards linked above also fit well next to each other in the USB slots. However, space might be tight next to the sound card if you want to connect a very wide USB stick. In this case, an extension cable or USB hub would also help.
Setup
Set up SD card and operating system
Download “Raspbian” as your operating system. It’s an adaptation of the Linux distribution Debian for the Raspberry Pi.
http://downloads.raspberrypi.org/raspbian_latest
Then extract the zip file to a directory of your choice.
You can copy the extracted *.img file to the SD card with the following command. To do this, you need to connect the card to your computer. Most devices already have integrated SD card slots; external card readers can be purchased for less than 5€ and are already present in many households due to digital cameras.
With the Linux command line, you can find out where your SD card is mounted with the following command:
df
Then enter:
sudo dd if=2014-01-07-wheezy-raspbian.img bs=1M of=/dev/sdZ
The filename after “if=” may of course have changed with a newer release date. It’s the name of the file you just extracted. After “of=” enter the mount point of the SD card that was output by the previous command.
Windows users can alternatively use the free software Win32 DiskImager instead of the command line.
Connect Raspberry Pi to the network
If you connect it to your network, in many cases a WiFi router from your internet service provider, with a cable, it’s not yet known under which IP address the new device is registered.
So insert the prepared SD card into your Raspberry Pi, connect it to the router with a network cable, and connect it to power to turn it on for the first time. The device automatically obtains an IP address via DHCP. The easiest way to find this out is to connect to your home router and log in. Every device has an overview of connected devices. The new device, usually named “raspberrypi,” is what we’re looking for. Note down the IP address.
All further steps are now performed via SSH. Under Linux this would be:
ssh pi@192.168.2.104
Replace the IP address after the @ with the address you already noted.
Windows users can best use the SSH client Putty instead of the command line.
Initial setup of the Raspberry Pi
After the SSH connection is successful, enter the following to set up the operating system:
sudo raspi-config
If a password is requested when entering commands, the following always applies: the default user is “pi,” the password during setup is always “raspberry.”
Select “Expand Filesystem.” This will use all the free space on the SD card for Raspbian. You can also select your preferred language and time zone under “Internationalisation Options.” Then continue under “Advanced Options.”
Select the “Memory Split” option. Here you can choose which part of the RAM should be used for graphics. Since we only want to listen to music, the Raspberry Pi has no screen, and we don’t use a graphical interface, you can enter the lowest value “16” here. This can be changed again later in the same way.
Exit the settings dialog and save the changes.
Assign a static IP address for the music server
Our device automatically obtains an IP address via DHCP and we found this out for the initial setup. But now we want a static address for the Raspberry Pi so that the address doesn’t change arbitrarily.
The easiest way here is to use your WiFi router’s menu again. Log in there, look at the overview of connected devices, and write down the MAC address of your Raspberry Pi. Alternatively, you can also find the MAC address directly when you’re connected to the Pi via SSH by entering:
ifconfig
The first line after “eth0” and Ethernet Hardware Address is the MAC address.
Look for something like “Static DHCP” in your router settings. There you can assign an IP address to the MAC address of your device, which this device will always use from now on.
Installation of the music server
We use software called MPD as our music server. This and several other programs need to be installed.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mpd nano alsa-utils usbmount
The installation will probably finish with some errors that are only relevant for IPv6. This doesn’t bother us at the moment.
sudo nano /etc/mpd.conf
Opens a text file where all settings for our music server are stored. The following lines need to be adjusted:
music_directory "/home/pi/music
bind_to_address "any"
audio_output [ device "hw:1,0" (enter for the USB sound card here, otherwise leave it at 0,0)
mixer_type "software" (remove # at the beginning of the line)
replaygain "album" (for volume adjustment)
volume_normalization "no" (audiophiles prefer to turn this off)
follow_inside_symlinks "yes"
auto_update "yes"
Then exit nano with Ctrl + X and save the configuration file.
Since we specified a different music directory above, we now need to create it. Change to the home directory of user “pi” and create a new directory.
cd /home/pi
mkdir music
Then we change to the newly created directory and set a symlink.
cd /home/pi/music
sudo ln -s /media/usb0 usb0
During the installation of mpd, we also installed a tool called “usbmount” above. This automatically detects plugged-in USB sticks and mounts them under /media/usb0 to 9. Since the latest model of the Raspberry Pi has four USB ports, it makes sense to create several links here in case multiple data storage devices are connected:
sudo ln -s /media/usb1 usb1
sudo ln -s /media/usb2 usb2
The first USB stick is then mounted under usb0, the second under usb1, etc. With the last command, we created a link in our music directory that points to a USB stick, provided one is plugged in. Through the “Auto-Update” option chosen above, MPD automatically updates the music library with all recognized music files located on plugged-in USB storage devices.
Then, to be safe, we set the permissions on our music directory again:
chmod -R 755 /home/pi/music/
Now you can reboot your Raspberry Pi and your music server is ready to operate.
sudo reboot
Control the music server
Setting up MPD has worked so far, but how do you control the device now that the Raspberry Pi has no keyboard and screen? Fortunately, through your home router you have a number of options:
- qmpdclient – (Linux) another player that you can easily install through your package manager, just like Gnome Music Player
- MPD Remote – (Android) for controlling with your smartphone via the WiFi of your home router
- For a list of other clients see the website of the MPD project.
How do I get music onto the Raspberry Pi?
- The easiest way is by connecting a USB stick. The music is automatically detected with the above settings and can be played from the stick. You can of course also copy the files normally if you’re somewhat familiar with the command line (if not, try “sudo apt-get install mc” and start with “mc” for a simple file explorer that works via SSH).
- With many file explorer programs, you can also establish a connection to your Raspberry Pi’s file system via SSH and then copy files there. Under Linux, these would be, for example, “Krusader” for KDE, or “Gigolo” for Gnome or XFCE.
What else can I do with the Raspberry Pi music server now?
- Connect a WiFi stick. Especially when your stereo system is far from your router. There are also good tutorials on the internet for setting up WiFi on the Raspberry Pi. I will soon publish a guide here with which I’ve had the best experiences.
- Set up additional services. With MPD alone, your Raspberry Pi is far from maxed out. On the same device, you could, for example, also accommodate other services such as: network storage, NAS and backup server, Owncloud, even a complete media server with internet TV is possible.
Update from December 6, 2014
Since the introduction of the Raspberry Pi B+ and 2 models, it’s no longer necessary to use an external USB hub. The model now has four USB ports, which means for this setup specifically that in addition to the external sound card and WiFi stick, two external storage media can be connected.
See also the post “What’s new with the Raspberry Pi B+“.
Update from October 27, 2020
Meanwhile, the fourth edition of the Raspberry Pi has reached the market and is significantly superior to its predecessors in terms of performance. Even the stripped-down basic version of the Raspberry Pi Zero is sufficient for the purpose described above. Only regarding connectivity via MicroUSB would one have to reconsider the use of an external sound card. However, I would still highly recommend it for uninterrupted musical enjoyment.

