Extending the Raspberry Pi to a miniature music center

External Hard Disks

If your music library resides on an external disk or another partition, you need to mount the appropriate drive to play the tracks and update the title database. Larger external hard disks are usually formatted with NTFS. Mounting these disks, therefore, requires the NTFS driver package ntfs-3g. To get the required mount modules, enter

sudo apt-get install ntfs-3g

at the command line. To integrate external hard drives automatically at boot time, you need to modify your /etc/fstab file. To discover the device name the kernel allocates to a USB disk, you need to call dmesg | tail once you have connected the drive with your Rasp Pi. For an external hard drive where your music collection is on the first (or only) partition, the device name is usually sdb1. The corresponding entry for /etc/fstab to mount the drive directly as the default MPD directory for music is shown in Listing 3.

Listing 3

Mount USB External Disk

# /etc/fstab
/dev/sdb1  /var/lib/mpd/music  auto  defaults  0  0

Network Shares

Network-attached storage (NAS) is a mass storage system that serves up its internal disks on the network. A small NAS usually comprises one or two hard drives in a compact housing with its own power supply. Most NAS drives provide their data on the LAN as Windows shares. To address these shares on Linux, you will need to install the Samba client using:

sudo apt-get install samba-client

A Windows share usually requires a username and a password for access. To avoid having to enter the password in the fstab file, which is readable for everyone, create a file with the appropriate login credentials and preferably store it in the /root directory. This file, which is usually named .smbcredentials, looks like:

# /root/.smbcredentials

Again, the share is integrated via the /etc/fstab file. The corresponding entry for a Samba share named MUSIC on the server at is:

# /etc/fstab
/var/lib/mpd/music  cifs credentials=/root/.smbcredentials,iocharset="utf8" 0 0

Optionally, you can set the character set to UTF-8, as I did here. A call to

sudo mount /var/lib/mpd/music

then mounts the directory without a reboot. Check the results, if necessary, by calling:

sudo mount -l -t cifs

You can then refresh the music database with MPC, the MPD client for the command line, by calling mpc update.

Buy this article as PDF

Express-Checkout as PDF

Pages: 6

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content