I am running Kubuntu 18.04 w/ KDE Plasma 5.12.6 off of a USB drive. This is a full install, not a Live version. The drive serves as a portable system that I can use with most physical computers.
To prevent any damage to the host computer's data. I do not want to automount any internal disk drives on boot. Even better, I'd like to completely disable those drives, so that even a normal sudo mount /dev/sdx
wouldn't work, but I'll settle for disabaling auto-mounting to start.
What I've tried
- The most commonly cited answer is to change the
org.gnome.desktop.media-handling automount
setting to false. I've done this using bothgsettings
from the command line as well as thedconf
gui editor. Both automount and automount-open are set to false - Removing my account (and all accounts) from the plugdev group.
- Confirming that the "Enable automatic mounting of removable media" setting in the Kubuntu
Removeable Devices
settings module is unchcked.
After trying all of these and rebooting, Kubuntu still mounts all discovered partitions, both those on the flash drive and any found on internal drives.
Solutions that won't work
- The other oft-mentioned solution is to disable the auto-mounting of specific devices by adding the device
fstab
along with anoauto
option. This solution does not help in my scenario, as I do not know what devices will be present when the system starts up. I would need to somehow configure fstab to default with a noauto for all devices.
Best Answer
The Auto-mounting of disks in Debian-based Linux distros (and perhaps others) comes from a service called udisks2.
Disabling this service will prevent any disk from automatically being mounted, while still allowing manual mounting.
Disable the service - No automatic or manual starts
Unmask the service - Will need to either manually run it or restart the computer
Stop the service temporarily - This will not persist across restarts
Get the status
Credit to @maxschlepzig for answering a similar question about OpenSUSE.