Raspberry Pi

Raspberry Pi Music Station with MPD

Linux has a lot of great desktop music players like Cementine, Amarok, and Rhythm Box. MPD (Music Player Deamon) is a music player that can be controlled remotely or from the command line. MPD is not a media streamer. It is only for playback on the server’s hardware. MPD can be configured per user or system-wide. We will set this up as a stand-alone music system with MPD running as a system-wide service. A Raspberry Pi with USB-attached storage is perfect for this.

Prepare the Raspberry Pi

Make a home for your music collection:

$ sudo mkdir -p /var/lib/mpd/music

Give ownership to your ssh user so you can move your music here:

$ sudo chown -R user:user /var/lib/mpd/music

Mount your USB storage at your new location and copy your music files to it. I like rsync:

$ rsync -av /path/to/local/music/ username@pi_ipaddress:/var/lib/mpd/music

I find it useful to store music as ‘/var/lib/mpd/music/AlbumArtist/Album/Track_number – Track_name,’ but this structure isn’t imperative since MPD will use your files’ tags to group artists, albums, and genres. Be sure your collection is well tagged using a tool like beets, EasyTag, or Picard. All music does need to be below one common directory. We will stick with ‘/var/lib/mpd/music.’

Install MPD

Log into the Pi and run:

$ sudo apt-get install mpd
$ sudo apt-get install alsa-utils

MPD will run as user ‘mpd.’ Adjust permissions so MPD can access your music files. MPD needs execute permissions for the directories in our library and it must have write permissions for the database and playlist files. It’s easiest to do:

$ sudo chown -R mpd:mpd /var/lib/mpd


Next we will configure mpd:

$ sudo vim /etc/mpd.conf

music_directory “/var/lib/mpd/music”
db_file “/var/lib/mpd/.mpd.db
playlist_directory “/var/lib/mpd/.playlists”
log_file “var/log/mpd/mpd.log”
pid_file “/run/mpd/pid”
state_file “/var/lib/mpd/.state”
sticker_file “var/lib/mpd/.sticker.sql”

user “mpd”
auto_update “yes
port “6600
bind_to_address “any”
audio_output {
device “hw:0.0
mixer_type “software”

An example configuration is located at ‘/usr/share/doc/mpd/mpdconf.example.’

Restart MPD:

$ sudo systemctl restart mpd

It may take a while, depending on the library’s size, for MPD to update its database. When manually updating the database use:

$ mpc up
$ sudo -u mpd mpc up

If you are having trouble setting the audio output device, run the command below to get a list of your audio devices.:

$ aplay --list pcm

Select a Client

Now, connect with any of a number of clients. You’ll be able to find MPD at your Pi’s ip address, port 6600. MAFA is a (paid) client for Android. It is polished and contains a lot of advanced features. ncmpcpp is a great client for the console written in C++. It’s very lightweight and has an extensive configuration file. Cantata is a full-featured graphical client for the linux desktop, written in Qt5.





There are plenty of artists not featured on Spotify or Tidal. If you’ve spent years collecting and ripping CDs you enjoy, MPD is a great way to experience your local collection of all your favorite artists. A Raspberry Pi is a very light, low-powered way to turn your flac and mp3 collection into a home sound-system.

About the author

Joseph M Gant

Joseph M Gant is a professional poet, fiction writer, and cyber-activist. His creative work has appeared widely in small and academic press, and his technical writing has appeared in various cybersecurity blogs. He is an Arch linux enthusiast of 10 years, EFF supporter, and self-confessed datahoarder.
Find him on Twitter or on Github