0

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.)

  • 3 lines in fstab, I would guess, but to mee this appears more a matter of changing udev rules (see here linuxconfig.org/… for a primer) – vanadium Dec 29 '19 at 16:06
  • I saw something about using udev rules, but it was based on a block device name, or a device type, and not a UID. I need my other external drive, which is also a 500GB Seagate Blue, to automount. I'll start looking into whether you can use this option by UID. – JasonF4 Dec 29 '19 at 16:10
  • Use the noauto parameter in /etc/fstab. See man fstab for more info. – heynnema Dec 29 '19 at 16:16
  • @ heynnema Yes, but the drive is mounted to three mount points. How do I add this to fstab? – JasonF4 Dec 29 '19 at 16:17
  • Three separate fstab entires, one for each partition. The same exact line that you would use to mount it, with the exception of the noauto parameter. – heynnema Dec 29 '19 at 16:18
1

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.

0

Auto-mounting was enabled in the File Manager (non-default Thunar), and this was overriding /etc/fstab. The setting in the File Manager (Volume Management) is all-or-nothing, mount external drives automatically, or don't. So I disabled that, and am controlling things with udev and fstab.

  • 1
    That would be Thunar, not Nautilus. Not a standard configuration. – heynnema Dec 31 '19 at 18:34
  • Correct. I changed to Thunar, and I don't have Nautilus on hand to check if it also has a volume management setting. – JasonF4 Dec 31 '19 at 19:31
  • Nautilus doesn't have such an option. I also updated my answer. – heynnema Dec 31 '19 at 19:59

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.