To add the LUKS encrypted kernel version 3.4.38 (32-bit) using Cryptsetup 2.3.4, LVM2 2.0.2.184, and OpenSSL 1.0.2u (Uranium) on a system with a keyfile located at /home/keyfile, you can follow these steps:
- First, ensure that your system has the required packages installed:
sudo apt-get update
sudo apt-get install cryptsetup lvm2 openssl
- Create a new LUKS encrypted device on
/dev/sdb2using the keyfile located at/home/keyfile:
sudo cryptsetup luksFormat --key-file /home/keyfile /dev/sdb2
No errors should be reported during the process.
- Open the LUKS encrypted device:
sudo cryptsetup open /dev/sdb2 crypt_sdb2
- Create a new physical volume for LVM:
sudo pvcreate /dev/mapper/crypt_sdb2
- Create a new volume group:
sudo vgcreate vg_crypt /dev/mapper/crypt_sdb2
- Create a logical volume for your needs:
sudo lvcreate -n lv_crypt -L 10G vg_crypt
Replace 10G with the desired size for your logical volume.
- Format the logical volume with an appropriate filesystem (e.g., ext4):
sudo mkfs.ext4 /dev/vg_crypt/lv_crypt
- Mount the logical volume:
sudo mount /dev/vg_crypt/lv_crypt /mnt/my_encrypted_volume
Replace /mnt/my_encrypted_volume with the desired mount point.
- To automatically mount the encrypted volume at boot, add the following lines to your
/etc/crypttab:
crypt_sdb2 /home/keyfile /dev/sdb2 none
- Add the logical volume to the
/etc/fstab:
/dev/vg_crypt/lv_crypt /mnt/my_encrypted_volume ext4 defaults 0 0
Replace /mnt/my_encrypted_volume with the desired mount point.
- Finally, reboot your system to test the automatic mounting:
sudo reboot
References
- LUKS: Linux Unified Key Setup (LUKS)
- Cryptsetup: Cryptsetup Manual
- LVM: Linux Logical Volume Manager (LVM)
- OpenSSL: OpenSSL Manual
Summary
- Install required packages:
cryptsetup,lvm2, andopenssl - Create a new LUKS encrypted device using the keyfile
- Create a new physical volume, volume group, and logical volume
- Format the logical volume with an appropriate filesystem
- Mount the logical volume and add it to
/etc/fstab - Automatically mount the encrypted volume at boot by modifying
/etc/crypttaband rebooting the system.