How can I prevent auto-mounting of a partition in fstab?
In order to avoid this issue make sure of 2 things:
- The partition is not mounted in /media
- 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.
Comments
-
Sparhawk over 1 year
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 over 10 years@Jobin I'll try commenting out the entire line. Oddly enough, another
noauto
entry in there still works/dev/sdb1 /media/3030-3030/ vfat user,noauto 0 0
. -
Malte Skoruppa over 10 yearsIn the bug report that you mentioned yourself, people suggest to use another mountpoint than one inside
/media
. This folder may get treated in a special way by Ubuntu, and some automount mechanism may mount it even though your/etc/fstab
says otherwise. Suggestion: move the mountpoint to somewhere else (/mnt/windowsHDD
or whatever) and try again. Don't forget to create the directory that you specify as mount point. -
Sparhawk about 10 years@MalteSkoruppa I tried changing the mountpoint to
/mnt/windowsHDD
. I forgot to create the directory (and I don't want it to automount anyway), but upon restart it was created and mounted there. -
Sparhawk about 10 years@Jobin commenting out the entire line results in automatic mounting at
/media/sparhawk/windowsHDD
. Oddly enough, when I do specify the location to mount in fstab, the files are marked green withls -l
. However, when I comment everything out, they are just a normal colour.
-
-
jobin over 10 yearsInstead of noauto, what if the line is commented?
-
Sparhawk over 10 years@Jobin I'll reply in the main comments below my question.
-
Mitch over 10 yearsAdd to fstab, will disable auto mounting. It's slightly different than your original, where you have to add noauto after the drives name.
/dev/sdaX /media/external-noauto ntfs user,noauto 0 0
Let me know. -
Sparhawk about 10 yearsThat didn't work either. Upon restart, the partition automatically mounted at
/media/external-noauto
instead. -
Mitch about 10 yearsHave you tried PySDM?
-
Sparhawk about 10 years@Mitch No, but from the screenshots, it looks like it can't prevent automatic mounting.
-
Sparhawk over 6 yearsUnfortunately I moved to Arch Linux a few years ago, so I can't really comment on whether this works or not. This problem went away with the migration and/or a KDE Plasma update. However, welcome to StackExchange and thank you for posting this answer. Hopefully it will be useful to others! (P.S. have an upvote.)
-
Angelo about 5 years"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." .... but why? It's been a long time since I've used labels, but this seems silly when it's explicitly set to noauto.
-
Mihail Malostanidis over 2 yearsdid you mean to mount
/mnt/testdir
withauto
and notnoauto
?