Ubuntu – How to Block Automounting of a Specific Drive (USB connection) With ** Three Mounted Partitions **

automountdata-recoveryddrescuefstabmount

I need to block the auto mounting of a specific external drive (USB connection, by UID) that has three different mount points (partitions)?

The contents of this drive were created with ddrescue – to copy the data from a failed drive.

The drive is being auto-mounted to three locations (sdc1,sdc3, sdc4), and it is being mounted read-write (bad). I can manually remount read-only. Most of the post-ddrescue tools need to have the drive unmounted. What is happening is the drive is being AUTOMATICALLY REMOUNTED (to the three mount points, r/w) when I exit the tools. I'm getting the new device mounting notifications – otherwise I would have never imagined this would happen.

I found instructions to block the auto-mounting of an external drive with a SINGLE mounted partition. You add an entry to fstab, using the UID. The instructions indicate you have to enter a mount point. But I have three mount points with this drive. How do I do this? Also, I would prefer to not define mounting points at all. I should be able to just block the auto-mounting of a device, by UID, period — where is has to be manually mounted by root.

UPDATE. This DID NOT work.

/etc/fstab

UUID=xxxx-xxxx /media/me/ESP vfat ro,noauto,nofail 0 0
UUID=xxxx-xxxx /media/me/DIAGS vfat ro,noauto,nofail 0 0
UUID=xxxxxxxxxxxxxxxx /media/me/WINRETOOLS ntfs ro,noauto,nofail 0 0
UUID=xxxxxxxxxxxxxxxx /media/me/OS ntfs ro,noauto,nofail 0 0

Partitions 1, 3, and 4 are still being auto-mounted, as before. (2 never was.)

Best Answer

In the man fstab page we find the noauto parameter...

  The fourth field (fs_mntops).
          This  field  describes  the  mount  options  associated with the
          filesystem.

          It is formatted as a comma-separated list of options.   It  con‐
          tains at least the type of mount (ro or rw), plus any additional
          options appropriate to the filesystem  type  (including  perfor‐
          mance-tuning options).  For details, see mount(8) or swapon(8).

          Basic filesystem-independent options are:

          defaults
                 use  default  options: rw, suid, dev, exec, auto, nouser,
                 and async.

          noauto do not mount when "mount -a"  is  given  (e.g.,  at  boot
                 time)

          user   allow a user to mount

          owner  allow device owner to mount

          comment
                 or x-<name> for use by fstab-maintaining programs

          nofail do  not  report errors for this device if it does not ex‐
                 ist.

Using sudo blkid you can easily determine the proper UUIDs to use.

You'll need to create these entries in /etc/fstab...

sudo -H gedit /etc/fstab

UUID=xxxx-xxxx /media/me/ESP vfat ro,noauto,nofail 0 0
UUID=xxxx-xxxx /media/me/DIAGS vfat ro,noauto,nofail 0 0
UUID=xxxxxxxxxxxxxxxx /media/me/WINRETOOLS ntfs ro,noauto,nofail 0 0
UUID=xxxxxxxxxxxxxxxx /media/me/OS ntfs ro,noauto,nofail 0 0

Update #1:

OP replaced Nautilus file manager with Thunar, and Thunar has a separate option to mount external drives. Disable that, and this all works as expected. Not a standard configuration.