how to mount by UUID without using /etc/fstab

https://unix.stackexchange.com/questions/349118/how-to-mount-by-uuid-without-using-etc-fstab

Asked 8 years, 10 months ago Modified 7 years, 10 months ago Viewed 70k times 28

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.

mount Share Improve this question Follow asked Mar 4, 2017 at 13:01 Necktwi’s user avatar Necktwi 1,07655 gold badges1515 silver badges2323 bronze badges Add a comment 2 Answers Sorted by:

Highest score (default) 39

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 Share Improve this answer Follow answered Mar 4, 2017 at 13:17 Thomas’s user avatar Thomas 6,66288 gold badges3131 silver badges3434 bronze badges Add a comment 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).

Share Improve this answer Follow answered Feb 18, 2018 at 2:13 cnst’s user avatar cnst 3,34122 gold badges2727 silver badges46

Updated: