Last active
November 21, 2023 08:58
-
-
Save daks/8030543 to your computer and use it in GitHub Desktop.
mpd configuration with music collection on removable usb disk, using autofs to automount when needed. Used on a RaspberryPi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/udev/rules.d/10-udev-disks.rules | |
# udev custom rule | |
# using # udevadm info -a -p $(udevadm info -q path -n /dev/sda1) | |
# I found the necessary information about my USB device | |
# and take the necessary ones to make it unique (idVendor, idProduct, serial here) | |
# when plugging the disk, nevermind the device name it gets (sda1, sdb1,...) udev creates /dev/mpd-disk and runs the script indicated | |
KERNEL=="sd?1",ATTRS{idVendor}=="xxxx",ATTRS{idProduct}=="yyyy",ATTRS{serial}=="zzzzzzzzzzzz",SYMLINK+="mpd-disk",RUN+="/root/bin/hdparm-mpd-disk.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/auto.master | |
# master configuration file for autofs | |
# add a line like this to handle mounting on /media/auto | |
# the timeout option unmounts the disk if not needed anymore | |
/media/auto /etc/auto.media --timeout=60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/auto.media | |
# specific autofs configuration file to handle /media/auto automouting | |
# mounts /dev/mpd-disk on /media/auto/mpd-disk | |
mpd-disk -fstype=auto :/dev/mpd-disk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# if you want to use idle features of your usb disk, check hdparm documentation with man hdparm | |
# in my case this checks the power status | |
hdparm -C /dev/sda | |
# and this sets idle timeout as 2 minutes | |
/sbin/hdparm -S 24 /dev/mpd-disk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/mpd.conf | |
# mpd configuration file | |
# only relevant directives noted here | |
# the music directory stays as default, this way when mpd starts but no music plays the usb disk is not mounted | |
music_directory "/var/lib/mpd/music" | |
follow_outside_symlinks "yes" | |
follow_inside_symlinks "yes" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# commands to use | |
# create a link to the real music collection | |
cd /var/lib/mpd/music | |
ln -s /media/auto/mpd-disk/Music Music | |
# make the script executable | |
chmod u+x /root/bin/hdparm-mpd-disk.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment