23

I am looking for command like

mount 1234-SOME-UUID /some/mount/folder

I am connecting a couple of external USB hard drives. I want them to be mounted on specific folders during startup. I am unable to boot using /etc/fstab if one of the drive is not connected. so I am using an init script. But /dev/sdbx enumeration is not always same to use with mount /dev/sdX /some/mount/folder in the init script.

2 Answers 2

34

From the manpage of mount.

-U, --uuid uuid
       Mount the partition that has the specified uuid.

So your mount command should look like as follows.

mount -U 1234-SOME-UUID /some/mount/folder

or

mount --uuid 1234-SOME-UUID /some/mount/folder

A third possibility would be

mount UUID=1234-SOME-UUID /some/mount/folder
3
  • On DragonFly BSD, you'd use /dev/part-by-uuid/.

  • On Debian GNU/Linux 7.11 (wheezy), /dev/disk/by-uuid/ is available (which I was able to easily find with find /dev -type d, as the output of ls -la /dev didn't seem to have anything relevant).

  • On FreeBSD 11.1, /dev/gptid/ would have you covered (likewise, as per find /dev -type d).


However, back to your original problem — not every filesystem described within fstab(5) has to be mounted at boot time — just annotate your removal disc within fstab with the noauto option, and it won't be mounted during boot (but you could still mount it by path, which would be much easier to manage than having to have UUIDs scattered all over the place).

The option “auto” can be used in the “noauto” form to cause a file system not to be mounted automatically (with mount -A or mount -a, or at system boot time).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .