Ubuntu – Removable HDD defined in fstab causing problems at startup when not present

external-hddfstabmount

Recently I made some edits in my fstab file after some change in my partitions. (check
Partitions mounted with fstab, not opening from Nautilus nor Unity sidebars ) In the process I wanted to include a removable device so it would be present for all users when it was present.

It automatically mounted as \media\activeuser\HDDMaker with user access permissions set to activeuser only. My idea was to mount it as \media\HDDMaker with access permissions to any user in a given group (gid=1004 common).

The fstab file looks like this:

UUID=543Exxxxxx  /mnt/543Exxxxxx  ntfs-3g  rw,nosuid,nodev,noexec,auto,gid=1004,umask=0002 0 0
/mnt/543Exxxxxx  /media/HDDMaker  auto     rbind,x-gvfs-show,x-gvfs-name=HDDMaker          0 0

This works fine when the HDD is attached to the computer at startup (except for the detail in my other question: Partitions mounted with fstab, not opening from Nautilus nor Unity sidebars ), but when the HDD is not attached I have two problems.

  1. It reports at startup that the device cannot be mounted. (and the startup process is halted until you press S)
  2. When plug, after the system is up, it doesn't automatically mounts. You have to manually mount it as

    sudo mount /dev/sdb1 /media/HDDMaker

The desired behavior is that it reports no problem at startup, and that, when plugged, it automatically mounts on /media/HDDMaker, with permissions set to all users in group common.

Best Answer

For an external drive, in order to prevent hold-up of the boot, the nobootwait option should be added to the fourth column in the /etc/fstab. Moreover, you should preferably use the UUID of the drive instead to ensure the right drive is always mounted (and see @Marty Fried’s comment to your question) so you get:

UUID=XXXXX  /media/HDDMaker  auto     rbind,x-gvfs-show,x-gvfs-name=HDDMaker,nobootwait          0 0

This post explains when and why this is a good method.

Furthermore, since fstab is run only on startup, unless you write a specific process to keep re-running it, you have to do a manual sudo mount -a to mount the disk if added afterwards, if you use the fstab option to auto-mount.

Therefore, a solution you could try instead, if you have Desktop Ubuntu, is to eschew fstab for this solution

Related Question