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.


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)



1. Get Arch linux image here:
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.

Paste and adapt the following configuration to fit your needs:

Save file and cd away from dir.
Activate profile:

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:

6. ssh to the alarmpi.

password is root.
7. Update system:
Adjust /etc/pacman.d/mirrorlist to a country near you.
Update system:

ssh back in to system after reboot.
8. Install mpd and mpc:

Edit mpd.conf so it looks like this:

Create media dir

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:

Enable and start mpd:

Check for errors:

9. I’ve found that autofs is the most reliable solution for removable storage:

Add automount to nsswitch.conf

Configure autofs:

Add external device:

Adjust to your needs. Usb drives usually come with a vfat filesystem, I use ext4 myself as you can see.
Enable autofs:

Cd to dir and check if it gets automounted with:

10. Set /etc/localtime and setup ntpd (adjust zoneinfo link to your needs):

Configure timesyncd to your country’s pool.
Enable and start 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:

Enjoy. If you have any questions please ask.

Delete from known_hosts – .bashrc function

Add to .bashrc:

Source .bashrc:

Delete offending line:

Dead simple templating with sed (gnuplot, ipvs, lvs)

I thought I’d share my simple templating technique with sed and bash I use to generate gnuplots. The example below is used to generate plot from data collected from a LVS-DR loadbalancer, using the following command:

Here’s the gnuplot template used:

The CAPS are the template placeholders.

And the simple script used to generate the actual plots, which is where the sed is used for templating:

Server Change Log Script

I’ve been a UNIX sysadm for several years now, and I have come to appreciate change logs on servers.

I wrote a script which I currently deploy to servers with puppet.

XMobar clickable workspaces

After years of using xfce for daily work I’ve headed back to tiling territory.

Stumbled on a git bug report discussing clickable workspaces with xmobar, which lead me to the xmobar plugin: UnsafeStdinReader that would enable escape sequences in workspace to be accepted by xmobar.

Below is a working example:

And the xmobarrc:

RHEL 6.4 – user crontabs – pam error

Recently after updating some customer systems from RHEL 6.3 to RHEL 6.4 user crontabs stopped working.

Checking crontabs with the user gave the following warning:

This is because /etc/pam.d/crond is configured with the access module and seperate /etc/security/access.conf entries for cron is needed:

XMonad – Clickable workspaces

One feature DWM has which is missing in XMonad is the clickable workspaces in status bar. There is a very good reason for this, which is that statusbars in XMonad are external applications i.e. XMobar and Dzen2.

To achieve clickable workspaces in XMonad with Dzen2 the following is needed:

– dzen2 (the latest SVN chekout which includes the ^ca functionality)
– XMonad
– xdotool

Include these modules in your xmonad.hs:

import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import Data.List

Comment out your current workspace listing and enter following instead:

If you have any redirects in your ManageHook change them accordingly:

If this does not work report back here: ** regj arch-ed dot dk **

Reference: McManiac @

Simulate port listen with Perl

On servers behind firewalls were netcat is not available this script can come in handy:

The above script takes to arguments: and

In effect:

would listen on port 3278 until someone tries to connect.

IO::Socket::INET is usually available on servers where Perl is installed.

The above version is a slightly modified version of a script found here:

systemd, lircd, mceusb, xbmc and Arch Linux

NOTICE!!! This guide may be outdated, please check if your distro has a suitable lircd.service already.

After migrating my Arch based media center to systemd, my IR mceusb remote stopped working with lircd.

I needed to do the following steps in order to make it function again.

1. Copy /usr/lib/systemd/system/lirc.service to /etc/systemd/system/lirc.service (service files in /etc/systemd/system always takes precedence to files located in /usr/lib/systemd/system).

2. Edit /etc/systemd/system/lirc.service accordingly:

The creation of the symlink to /dev/lirc eliminates lircd errors like this:

There may be more “correct” ways of fixing this, but creating the symlink satifies lircd.

3. Now adjust variables in /etc/conf.d/lircd.conf:

My /etc/lirc/lircd.conf looks like this and works with a mceusb based RC:

4. Disable lircd conflicting kernel modules by creating a blacklist file /etc/modprobe.d/blacklist_mce.conf containing:

Reboot or remove these modules using modprobe -r.

5. Reenable lirc.service:

Performance reporting with bash, gnuplot and LaTex

In an earlier earlier blog post I demonstrated how to create a simple CPU performance graph using the TiKz LaTeX class. I soon found out that generating graphs for longer periods and for many servers using TiKz took a very long time to compile and I started to look for other solutions – GNUplot with the gnuplottex class proved to be the right solution.

It all starts out by collecting data on the individual servers using the following bash script as a cronjob, which saves the data to a NFS share:

The reason it is run locally on the server is because sar data files are not backwards compatible with earlier versions of sadf and vice-versa.

This cron job runs every day a 23:55 :

Since I need to create graphs for many servers using SAR data extracted from the servers I created the following template:

This template gets filled out, the data handled and the PDFs compiled by the following script:

Which creates graphs that looks like this:

testservergraph (PDF)