How do I disable the auto-mounting of internal drives in Ubuntu or Kubuntu 18.04

Solution 1:

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

systemctl status udisks2

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