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,989
  • 1
    @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. – Sparhawk Feb 16 '14 at 10:30
  • In 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. – Malte Skoruppa Feb 16 '14 at 12:00
  • @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 Feb 18 '14 at 05:55
  • @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 with ls -l. However, when I comment everything out, they are just a normal colour. – Sparhawk Feb 18 '14 at 05:57

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
  • 1
    Unfortunately 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.) – Sparhawk Sep 25 '17 at 01:09
  • 3
    "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. – Angelo May 02 '19 at 13:36
  • 1
    did you mean to mount /mnt/testdir with auto and not noauto? – Mihail Malostanidis Dec 05 '21 at 10:47
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,764
-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,937
  • Instead of noauto, what if the line is commented? – jobin Feb 16 '14 at 10:18
  • 1
    @Mitch Are you saying to add that line to fstab? Your second and third sentences suggest to run it as a command. Also, it seems like it's essentially identical to my original line, except it's ext4 when my disk is really ntfs. I want to be able to mount it at the listed location if needed, just not automatically. – Sparhawk Feb 16 '14 at 10:22
  • @Jobin I'll reply in the main comments below my question. – Sparhawk Feb 16 '14 at 10:29
  • Add 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. – Mitch Feb 16 '14 at 10:38
  • That didn't work either. Upon restart, the partition automatically mounted at /media/external-noauto instead. – Sparhawk Feb 18 '14 at 05:53
  • Have you tried PySDM? – Mitch Feb 18 '14 at 06:26
  • @Mitch No, but from the screenshots, it looks like it can't prevent automatic mounting. – Sparhawk Feb 21 '14 at 14:55