8

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 both gsettings from the command line as well as the dconf 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 a noauto 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.
  • 1
  • @Panther thanks, that worked. As the question/solution is for an older version of Linux, and specifically marked for openSUSE, do you want to write up your comment as an answer? Based on other questions, I think that this is a fairly common request, especially for Kubuntu. – BrianHVB Aug 7 '18 at 2:29
  • @BrianHVP go ahead , give credit as to the source – Panther Aug 7 '18 at 6:45
  • I found the solution: write a custom udev rule. – Chris Chen Oct 9 at 19:33
5

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

systemctl mask udisks2

Unmask the service - Will need to either manually run it or restart the computer

systemctl unmask udisks2
systemctl unmask udisks2.service

Stop the service temporarily - This will not persist across restarts

systemctl stop udisks2.service

Get the status

sudo systemctl status udisks2

Credit to @maxschlepzig for answering a similar question about OpenSUSE.

0

This is not really an answer to the original question, but a comment that I had an unwanted side-effect with this solution on Ubuntu 18.04 using cinnamon. Disabling udisks2 helped for me too, but as described here cannot start nemo if udisks2 is disabled I then had the problem that file manager nemo did not start anymore. The solution for me was to disable the option "Automatic mount removable media when inserted and on startup" in the "Behavior" tab of nemo's preferences.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.