I find the following somewhat confusing, but it doesn't have many steps. Is this a solid method for encrypting a hdd with LUKS?
Here’s the process in few steps:
Create a LUKS partition
cryptsetup luksFormat --hash=sha512 --key-size=512 --cipher=aes-xts-plain64 --verify-passphrase /dev/sdaNote that obviously you can use different settings for the luksFormat command; above it’s what i usually use. After that you will be asked to enter a password for the encryption, it doesn’t matter if it’s not very secure now, because we will only use this device as random data generator.
Open the encrypted device: the command below opens the luks device and maps it as "sda_crypt"
cryptsetup luksOpen /dev/sda sda_cryptNow we fill this device with 0s using
ddand/dev/zeroas source:dd if=/dev/zero of=/dev/mapper/sda_crypt bs=1MAll the underlying disk appears now to be filled with random data, minus the LUKS header that we are about to override (you can take a look using
hexdump /dev/sda | lesscommand). Usually the header takes few Megabytes, but to avoid calculations and be rude we will cover the first 10 Megabytes of the disk. We will useddwith/dev/urandomas random data source this time:# first destroy the mapping cryptsetup luksClose sda_crypt # override the header dd if=/dev/urandom of=/dev/sda bs=512 count=20480We have now the disk full of random data. Now for the serious stuff. Just repeat steps 1 and 2 but this time use a very secure passhrase, because it will be the key to unlock your disk
Now we will use the device as phisical volume…
pvcreate /dev/mapper/sda_cryptNow create a volume group (I will name it
vg00) that will contain the phisical device/dev/mapper/sda_cryptvgcreate vg00 /dev/mapper/sda_cryptCreate the logical volumes. I usually use 4: one for root, one for the swap partition, one for /home and the other for a data partition, but this is obviously up to you. The “+100%FREE” options on the last line modifies the command to use logical extents instead of size, and to use all of the free remaining ones for that logical volume.
lvcreate -n lv00_swap -L 4G vg00 lvcreate -n lv01_root -L 30G vg00 lvcreate -n lv02_home -L 10G vg00 lvcreate -n lv03_data -l +100%FREE vg00Now create the boot partition on a separate device, ideally an usb stick, and install GRUB on the MBR of this device. With this setup we both will have no clear partitions on our encrypted disk, and no chance to boot the system without the external device, which adds an extra layer of security.