I recently obtained a disk dock and cloning unit (StarTech.com) for working with some of my internal drives (I have too many). This unit does a bit-by-bit clone of one disk to another, which is really useful! The problem with this is that each disk now looks exactly the same to your Operating System, meaning there is no way to mount them both at the same time!

Furthermore, I decided to create a LUKS encrypted drive protecting an ext4 partition. This means that both the LUKS layer and the ext4 layer have their own UUID’s, which both need to be changed.

After doing some quick google’ing, I successfully did this in no-time!

There is a fancy library called libuuid you can utilize to generate a uuid using uuidgen on the cli! It already comes with the e2fsprogs package so you should have it!

Get drive info

sudo blkid
/dev/sdb: UUID="0bbfe23e-921f-46df-89a0-e299032688ef" TYPE="crypto_LUKS"
/dev/mapper/luks-0bbfe23e-921f-46df-89a0-e299032688ef: LABEL="44plus" UUID="ced07e6b-f0f6-4d07-81d6-58999306e14e" TYPE="ext4"

Change ext4 partition UUID

Note that I decided to do the ext4 partition first, and then unmount and do the LUKS layer. Either way should work just fine, just ensure you point to the correct luks-* mountpoint!

sudo tune2fs -U 6a62939e-9d02-4cd1-ad50-297d166daf23 /dev/mapper/luks-0bbfe23e-921f-46df-89a0-e299032688ef

Change luks UUID

sudo cryptsetup luksUUID --uuid=5371cc8d-c027-4f4d-aa49-19d32efd57d0 /dev/sdb

Now you can successfully mount both drives on the same machine!

Mario Loria is a builder of diverse infrastructure with modern workloads on both bare-metal and cloud platforms. He's traversed roles in system administration, network engineering, and DevOps. You can learn more about him here.