16

Previously, I prevented auto-mounting of a particular partition at boot by the following line in /etc/fstab

UUID=<alphanumeric> /media/windowsHDD ntfs user,noauto 0 0

At some point in the last year, this failed, and the partition was automatically mounted on boot. I attempted the following, which also failed.

/dev/sda1 /media/windowsHDD ntfs user,noauto 0 0

Thinking that perhaps I was bitten by this bug, I removed user, but that also failed.

UUID=<alphanumeric> /media/windowsHDD ntfs noauto 0 0

Is there a way to prevent auto-mounting in fstab?

Sparhawk
  • 6,969

3 Answers3

10

In order to avoid this issue make sure of 2 things:

  1. The partition is not mounted in /media
  2. The the name of the target mount directory is different than the partition label value

Check entry in /etc/fstab:

user@raspberrypi:/ $ cat /etc/fstab
/dev/sda1     /media/st1       ntfs-3g noauto,rw         0       0

Check the label of the partition:

user@raspberrypi:/ $ sudo ntfslabel -f /dev/sda1 
st1

Since the name of target mount directory (/media/st1) equals the partition label (st1), the partition will continue to mount automatically despite the noauto parameter in /etc/fstab.


Let's do something to avoid the automatic mount. Create a new directory in /mnt:

user@raspberrypi:/ $ sudo mkdir /mnt/testdir

Edit the /etc/fstab entry:

/dev/sda1     /mnt/testdir       ntfs-3g auto,rw         0       0

Finally change the label of the partition and reboot:

user@raspberrypi:/ $ sudo ntfslabel /dev/sda1 "new_label"

user@raspberrypi:/ $ sudo reboot

The partition shouldn't be mounted automatically anymore.

hymx
  • 101
0

The noauto-option will only prevent a partition to be mounted during boot via fstab and also will prevent a partition to be mounted via the mount -a-command.

The noauto-option will not prevent a partition to be automatically mounted during boot or login via other methods. Nowadays most (if not all) filemanagers provide methods to automount partitions and these methods may have nothing to do with fstab. In such a case, you will have to configure your filemanager according to your demands.

mook765
  • 18,644
-4

Try addind this to /etc/fstab. Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

/dev/sdaX /media/external-noauto ext4 user,noauto 0 0

Or you can use PySDM

Make sure you replace X with your device ID.

Mitch
  • 109,787