Mounting LUKS-encrypted disks by UUID

I have a machine with two external storage disks attached to it - one an SSD, and one an HDD.

Both are LUKS-encrypted.

On a reboot of the machine, I want them unlocked and mounted to specific mount points.

They are not consistent with their /dev partition names: sometimes one is /dev/sdb, sometimes it is the other one.

So mount them via uuid instead.

Use blkid to identify the disk’s UUID. This is different to the “Disk identifier”.

Then unlock using /dev/disk/by-uuid/$UUID rather than /dev/$partition_name:


/usr/sbin/cryptsetup luksOpen /dev/disk/by-uuid/include-your-uuid-from-blkid-here name-of-mapper --key-file=/path/to/keyfile

/usr/bin/mount /dev/mapper/name-of-mapper /your/chosen/mount/point