Debian Command Line – Mount Drive Using UUID Without fstab

command linedebianmount

Is it possible to use UUIDs to mount drives, rather than using these values in fstab?

I have a script which mounts devices, however there is no way to guarantee that the drive labels such as /dev/sda2 will always be the same.

I'm aware I can mount the drive at boot time using this method with fstab, however in the case of external disks, they may not always be present at boot time.

Best Answer

Yes it's possible, you just use the UUID option:

lsblk -o NAME,UUID
NAME      UUID
sdc       
├─sdc1    A190-92D5
└─sdc2    A198-A7BC

sudo mount -U A198-A7BC /mnt

Or

sudo mount UUID=A198-A7BC /mnt

Or

sudo mount --uuid A198-A7BC /mnt

The mount --help:

Source:
 -L, --label      synonym for LABEL=
 -U, --uuid        synonym for UUID=
 LABEL=           specifies device by filesystem label
 UUID=             specifies device by filesystem UUID
 PARTLABEL=       specifies device by partition label
 PARTUUID=         specifies device by partition UUID
                 specifies device by path
              mountpoint for bind mounts (see --bind/rbind)
                   regular file for loopdev setup
Related Question