How to Mount an Encrypted LUKS Partition without Password using Keyfile
2 minutes read •
Setup the keyfile
- Create the keyfile with which we’re gonna decrypt the encrypted partition.
-
The default location for cryptsetup key files is
/etc/cryptsetup-keys.d/cryptdevicename.key. If no kefile is mention in thecrypttabfile then systemd will look into that default location. -
Add the key to the disk header.
- Check if the keyfile was added successfully. If you see another key slot is enabled (In this case the second key or Key slot 1), then it was successful.
|
Or,
|
- Check if the encrypted partition unlockes with that keyfile.
- Close the encrypted partition.
Auto mount on boot time
- Get the
UUIDof the encrypted partition.
|
- The
/etc/crypttabconfig file to decrypt and mount the encrypted partition on/dev/mapper/.
# /etc/crypttab configuration file
The nofail option is to be used for secondary non-root partitions on which the boot does not rely. The nofail option allows the system to continue boot without waiting for this partition to decrypt. Otherwise, the system will wait for it to decryp which will slow down boot time.
- On
systemdsystems perform:
- Check if the config is working.
)
)
Or,
- Then configure the
/etc/fstabconfig file to mount the mapped device.
# /etc/fstab file
- It’s better to limit the permission on the keyfile.
Done!