Monday, 6 June 2011

Configure systems to mount file systems at boot by Universally Unique ID (UUID) or label

A nice and short objective.

Remember in my last post how I added a label to the my luks encrypted logical volume, I gave it the label LUKS, so I can now mount it with the following command:

mount -L LUKS /encdir

The UUID can be found by issuing the following command:

blkid - This has this edited output
/dev/mapper/volname-lvol3: UUID="d1e50970-2995-4749-b9b1-46a52169a305" TYPE="crypto_LUKS"
/dev/mapper/lukslv: LABEL="LUKS" UUID="d71b791d-3f09-4419-bedd-ae9bc0ed0989" TYPE="ext4"
The first device represents the logical volume itself, whereas the second device is what we are interested in, the encrypted device, thus the UUID we want is d71b791d-3f09-4419-bedd-ae9bc0ed0989.

So, we can also mount by using this command:

mount -U d71b791d-3f09-4419-bedd-ae9bc0ed0989

Of course, the two commands above will only temporary mount the device, so we need to edit the fstab file again.

To mount by label you can do it with the following command:

echo "LABEL=LUKS /encdir ext4 defaults 1 2" >> /etc/fstab

and to mount by UUID you need to modify the fstab file like this:

echo "UUID=d71b791d-3f09-4419-bedd-ae9bc0ed0989 /encdir ext4 defaults 1 2" >> /etc/fstab

You could also edit /etc/fstab. At any rate, make sure that you only have one entry that mounts the encrypted device.

You can test your /etc/fstab file by issuing the following command, which will attempt to mount everything on /etc/fstab: mount -a

No comments:

Post a Comment