Arch, Raspberry PI, MPD, DAC = Hi-Fi

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

For:

Against:

Guide

  1. Get Arch linux image here: http://www.raspberrypi.org/downloads/
  2. Write image to SD card:
  3. Before booting the Pi the first time it will be helpful to configure wireless using netctl so the machine can be accessed via ssh.
    sudo mount /dev/mmcblk0p5 /mnt
    cd /mnt/etc/netctl
    sudo vi wlan0-pi-conf
    Paste and adapt the following configuration to fit your needs:
    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
  4. Transfer SD card to you PI and turn on power. Watch the wireless dongle to check for activity.
  5. Scan your network to identify with nmap (adjust ip-range to match your local network)i:
    nmap -sP 192.168.0.1-20
  6. ssh to the alarmpi.
    ssh -l root 
    password is root.
  7. Update system:
    Adjust /etc/pacman.d/mirrorlist to a country near you.
    Update system:
    pacman -Syu
    reboot
    ssh back in to system after reboot.
  8. Install mpd and mpc:
    pacman -S mpd mpc alsa-utils
    Edit mpd.conf so it looks like this:
    user "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"
    }
    Create media dir
    mkdir /media
    You need to adjust audio_output variables to fit your external DAC and adjust music_directory to where you store your music.
    Read mpd.conf man page for more information on the variables.
    Since mpd will run as mpd change ownership of the mpd dirs:
    chown -R mpd /var/lib/mpd
    Enable and start mpd:
    systemctl enable mpd && systemctl start mpd
    Check for errors:
    journalctl -xn
  9. I’ve found that autofs is the most reliable solution for removable storage:
    pacman -S autofs
    Add automount to nsswitch.conf
    echo "automount: files" >> /etc/nsswitch.conf
    Configure autofs:
    echo "/-     /etc/autofs/auto.rpi" >> /etc/autofs/auto.master
    Add external device:
    echo "/media/musik -fstype=ext4,async,nodev,nosuid :/dev/sda1" >> /etc/autofs/auto.rpi
    Adjust to your needs. Usb drives usually come with a vfat filesystem, I use ext4 myself as you can see. Enable autofs:
    systemctl enable autofs && systemctl start autofs
    Cd to dir and check if it gets automounted with:
    df -h
  10. Set /etc/localtime and setup ntpd (adjust zoneinfo link to your needs):
    rm /etc/localtime && ln -s /usr/share/zoneinfo/Europe/Copenhagen /etc/localtime
    Configure timesyncd to your country’s pool.
    Enable and start timesyncd:
    systemctl enable systemd-timesyncd && systemctl start systemd-timesyncd
  11. 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:
    wget http://live-icy.gss.dr.dk/A/A22H.mp3.m3u && mpc load A22H.mp3.m3u
    Enjoy. If you have any questions please ask.