How to automount optical media on Debian Linux for Kodi
This problem has been bugging me for a while: how to setup my Kodi based home cinema to automatically mount an optical media ?
Turns out the solution is quite simple, now that Debian has switched for
systemd. Just add the following line to
/dev/sr0 /media/bluray auto defaults,nofail,x-systemd.automount 0 2
/dev/sr0is the device file. You can also use one of the symbolic links setup by
/media/blurayis the mount point. You can choose another mount point
nofailis required to avoid failure report when booting without a disc in the optical drive
x-systemd.automountis the option to configure
systemdto automatically mount the inserted disc
Do not specify
noauto: this would prevent
systemd to automatically mount a disc, which defeats the purpose.
To test you setup:
- Run the command
journalctl -x -fin a terminal to check what is going on with
sudo systemctl daemon-reload.
- load a disc in your optical drive
journalctl should show something like:
Sept. 27 16:07:01 frodo systemd: Mounted /media/bluray.
And that’s it. No need to have obsolete packages like
Last but not least: this blog is moderated, please do not waste your time (and mine) posting rants about systemd.
Edited: I’ve later realised that the instruction contained in this post works only if the mount point is opened, e.g. a program opens the mount point directory to check its content. Unfortunately, it’s not enough for kodi: once a media is plugged, systemd makes sure that the plugged device is ready to be mounted, but kodi does not know this. See this Automount usb devices with systemd for a solution.
All the best.