How can I prevent auto-mounting of a partition in fstab?

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.