Ubuntu – How to mount a luks encrypted partition at boot

bootencryptionluksmountpartitioning

I have been given a task to creat a LUKS encrypted partition and then mount it, here are the steps I followed:

  1. Create the partition for encryption:

    sudo fdisk /dev/sda
    
  2. Reboot

  3. Format the partition with cryptsetup:

    sudo cryptsetup luksFormat /dev/sda3
    
  4. Open encrypted partition:

    sudo cryptsetup luksOpen /dev/sda3 secret-disk
    
  5. Add the following to /etc/crypttab:

    secret-disk       /dev/sda3
    
  6. Make filesystem on partition:

    sudo mkfs -t ext3 /dev/mapper/secret-disk
    
  7. Make mount directory:

    sudo mkdir /secret
    
  8. Add the following to /etc/fstab:

    /dev/mapper/secret-disk   /secret   ext4 defaults 1 2
    
  9. Mount partition at /secret:

    sudo mount /secret OR sudo mount -a
    
  10. Reboot.

Problem: During reboot, the mount instruction in fstab returns the error : device not ready or not present. And I have to enter S to skip the mount so ubuntu can boot or M to recover it manually. I have checked this option but it does not solve mine. How do I get the encrypted partition to mount at /secret.

Best Answer

The solution was to add this secret-disk /dev/sda3 none luks to the /etc/crypttab file as admin and reboot. The passphrase will be requested, and the encrypted partition unlocked.

Related Question