Auto-Attaching and Auto-Mounting LUKS Volume During Boot

  1. Open /etc/crypttab and add below content.

›_ crypttab file

mydisk UUID=0a9571f8-11f5-4e35-acc6-c4c35c5390d1 - pkcs11-uri=auto 
  1. Use the command below to start the network service before running system-cryptsetup service.

›_ Console

# grubby --update-kernel=ALL --args="rd.neednet=1" 
  1. Reboot the system.

  2. There is a password prompt during the boot for attaching LUKS volume. Provide the slot PIN when prompted.

image-3284992173-1.jpg

Boot window

  1. Once the system is up, verify that status of systemd-cryptsetup service.

›_ Console

# systemctl status systemd-cryptsetup@mydisk.service 
image-3284992173-2.jpg

systemd-cryptsetup service status

  1. Format the volume with File System.

›_ Console

# mkfs.xfs /dev/mapper/mydisk 
  1. Create one directory for mounting the volume.

›_ Console

# mkdir /mnt/hdd 
  1. Get UUID of /dev/mapper/mydisk.

›_ Console

# blkid 
  1. Add below entry in /etc/fstab.

›_ fstab file

UUID=7f514a18-c3e7-4e35-b975-d68ceb624bcf   /mnt/hdd xfs    defaults       0 0 

Here UUID is for /dev/mapper/mydisk.

  1. Run below command to mount the encrypted volume.

›_ Console

# mount -a 
image-3284992173-3.jpg

Mounting LUKS volume

If the above command does not work, troubleshoot accordingly.

  1. Next, reboot the system and check if the reboot halts waiting for LUKS passphrase to mount the encrypted device.

image-3284992173-4.jpg

Boot window

Provide slot PIN when prompted.

  1. When the system is up and running, verify that the encrypted volume is mounted automatically.

›_ Console

# df -Th 
image-3284992173-5.jpg

Listing mounted volumes