Arch, Raspberry PI, MPD, DAC = Hi-Fi
Yesterday I setup a headless Raspberry PI Arch based MPD server. It was a breeze (for me) and I thought I’d like to share the procedure with you guys. If you intend to use a Debian image the guide below will not work without adapting the configuration for Debian – other guides cover this.
96Khz and 192Khz 24bit files work flawlessly.
Resources:
http://www.musicpd.org/
http://www.raspberrypi.org/downloads/
https://wiki.archlinux.org/
https://wiki.archlinux.org/index.php/Autofs
Hardware
- Raspberry PI Model B
- Edimax ew-7811un wireless usb dongle
- Powered USB hub (mine is 7 port logik brand)
- External USB Storage for music (or smb/nfs mount)
- External USB DAC (Mine is Cambridge Audio DacMagic Plus)
- 2 GB SD card (I use a 4 GB, which more than is needed)
For:
- Remotely controlled via smart phone
- Headless aka screenless
- Does not hurt too much budget wise
Against:
- Moderate command line profiency is needed
- Access to Linux command line is presumed
Guide
- Get Arch linux image here: http://www.raspberrypi.org/downloads/
- Write image to SD card:
- Linux
http://www.raspberrypi.org/documentation/installation/installing-images/linux.mdsudo dd if=ArchLinuxARM-<current-version>-rpi.img bs=1M of=/dev/mmcblk0u
- Windows:
http://www.raspberrypi.org/documentation/installation/installing-images/windows.md - Mac:
http://www.raspberrypi.org/documentation/installation/installing-images/mac.md
- Linux
- Before booting the Pi the first time it will be helpful to configure wireless using netctl so the machine can be accessed via ssh.
Paste and adapt the following configuration to fit your needs:sudo mount /dev/mmcblk0p5 /mnt cd /mnt/etc/netctl sudo vi wlan0-pi-conf
Description='Wireless network for my MPD Pi' Interface=wlan0 Connection=wireless Security=wpa ESSID=<your-ssid> IP=dhcp Key=<your-wlan-password>
Save file and cd away from dir.
Activate profile:
sudo ln -s /usr/lib/systemd/system/netctl-auto@.service /mnt/etc/systemd/system/multi-user.target.wants/netctl-auto@wlan0.service sudo umount /mnt
- Transfer SD card to you PI and turn on power. Watch the wireless dongle to check for activity.
- Scan your network to identify with nmap (adjust ip-range to match your local network)i:
nmap -sP 192.168.0.1-20
- ssh to the alarmpi.
password is root.ssh -l root
- Update system:
Adjust /etc/pacman.d/mirrorlist to a country near you.
Update system:
pacman -Syu
ssh back in to system after reboot.reboot
- Install mpd and mpc:
Edit mpd.conf so it looks like this:pacman -S mpd mpc alsa-utils
Create media diruser "mpd" pid_file "/run/mpd/mpd.pid" db_file "/var/lib/mpd/mpd.db" state_file "/var/lib/mpd/mpdstate" playlist_directory "/var/lib/mpd/playlists" music_directory "/media" mixer_type "software" audio_output { type "alsa" name "Cambridge Audio USB Audio 2.0" devic "hw:1,0" }
You need to adjust audio_output variables to fit your external DAC and adjust music_directory to where you store your music.mkdir /media
Read mpd.conf man page for more information on the variables.
Since mpd will run as mpd change ownership of the mpd dirs:
Enable and start mpd:chown -R mpd /var/lib/mpd
systemctl enable mpd && systemctl start mpd
Check for errors:
journalctl -xn
- I’ve found that autofs is the most reliable solution for removable storage:
Add automount to nsswitch.confpacman -S autofs
Configure autofs:echo "automount: files" >> /etc/nsswitch.conf
Add external device:echo "/- /etc/autofs/auto.rpi" >> /etc/autofs/auto.master
Adjust to your needs. Usb drives usually come with a vfat filesystem, I use ext4 myself as you can see. Enable autofs:echo "/media/musik -fstype=ext4,async,nodev,nosuid :/dev/sda1" >> /etc/autofs/auto.rpi
Cd to dir and check if it gets automounted with:systemctl enable autofs && systemctl start autofs
df -h
- Set /etc/localtime and setup ntpd (adjust zoneinfo link to your needs):
Configure timesyncd to your country’s pool.rm /etc/localtime && ln -s /usr/share/zoneinfo/Europe/Copenhagen /etc/localtime
Enable and start timesyncd:
systemctl enable systemd-timesyncd && systemctl start systemd-timesyncd
- Install mpdroid or similar app on your phone. Point the app to the ip of your rpi.
Bonus info:
You can add radio channel streams to mpd’s playlists. I’ve only tried m3u links.
Example for Danish Radio’s Jazz station:
Enjoy. If you have any questions please ask.wget http://live-icy.gss.dr.dk/A/A22H.mp3.m3u && mpc load A22H.mp3.m3u