Starting systemd Services when Encrypted Device is plugged in


Problem: You want to start a service only once an encrypted harddrive is plugged in. On our embedded iconnect box, we run an mpd whose music collection is stored on an external, encrypted hdd. The mpd should only start when the device is plugged in, since otherwise it would rescan its collection every time the hdd is not present. To achieve that, we can use systemd’s ability to define dependencies.