Can I mount a drive using UUID from the command-line (Not fstab?)
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
If you're interested in having an fstab
entry for a drive which may not be present at boot time, you have two options which can help: noauto
and nofail
:
noauto
: do not mount when "mount -a" is given (e.g., at boot time)
nofail
: do not report errors for this device if it does not exist.
Imagine you have an fstab
entry
UUID={YOUR-UID} /mnt/data ext4 defaults
If you add noauto
to the options, the system will not attempt to mount the drive at boot time. You'll be able to mount it manually with mount /mnt/data
.
If you add nofail
, the system will try to mount the drive at boot time, but if the drive is not present the boot sequence will not be interrupted. You'll be able to mount the drive if you plug it later using mount /mnt/data
.
You can use the system-provided symlinks:
mount /dev/disk/by-uuid/{YOUR_UUID} /mnt