Hi,
I am running both Ubuntu and Manjaro with root on btrfs inside luks in a Raid 1 setup. For Manjaro, I pretty much followed the guide in this thread, whereas for Ubuntu I used steps similar to 01 Installing Ubuntu1804 with btrfs, raid and encryption - YouTube
Here are (more or less) the required post-install steps, i.e. after you set up your root on btrfs inside luks system (as described in the above guide in this thread):
Step 1: Make identical partitions on second harddrive for raid 1
Use parted to have the same partition layout on your second harddisk, including your efi, boot and luks partition, so something like that:
#Assume vda is your harddisk with the btrfs operating system
parted /dev/vda
unit b
print
# write down all begin and end sectors of your harddisk
q
# Aussme vdb should be used for raid1
parted /dev/vdb
unit b
print
#repeat the following command to clone vda
mkpart primary begin_some_number end_some_number
#you might also want to change the name
q
Step 2: Create luks partition
cryptsetup luksFormat --type=luks1 /dev/vdb3
cryptsetup luksOpen /dev/vdb3 vdb3_crypt
blkid #write down your uuid
If you use keyfiles to unlock your lukspartition add it. By default the keyfile is stored in /crypto_keyfile.bin:
cryptsetup luksAddKey /dev/vdb3 /crypto_keyfile.bin
Step 3: Create raid 1
swapon # any swapfiles? if so deactivate these with swapoff and remove the files as swapfiles are not compatible with btrfs-raid1
btrfs fi show /
btrfs device add /dev/mapper/vdb3_crypt /
btrfs fi show /
btrfs balance start -dconvert=raid1 -mconvert=raid1 /
btrfs fi show /
btrfs fi usage / #check that there is no single or DUP left, otherwise rerun balance with -dusage=90 and -museage=90 or some other high number
Step 4: Create additional hook encrypt2 and add cryptdevice2 to grub
This is taken from blog.wohli.org and Dm-Crypt Arch Wiki
Add additional hook that will be used by the initramfs to unlock the second root partition:
# copy the original hook
cp /usr/lib/initcpio/install/encrypt /etc/initcpio/install/encrypt2
cp /usr/lib/initcpio/hooks/encrypt /etc/initcpio/hooks/encrypt2
# adapt the new hook to use different names and to NOT delete the keyfile
sed -i "s/cryptdevice/cryptdevice2/" /etc/initcpio/hooks/encrypt2
sed -i "s/cryptkey/cryptkey2/" /etc/initcpio/hooks/encrypt2
sed -i "s/rm -f \${ckeyfile}//" /etc/initcpio/hooks/encrypt2
Now, add encrypt2 hook to mkinitcpio.conf BEFORE encrypt hook (because encrypt hook deletes the key file at the end) and include the keyfile:
nano /etc/mkinitcpio.conf
# Add the following
# FILES="/crypto_keyfile.bin"
# HOOKS=" ... udev encrypt2 encrypt ... " #(before "filesystems")
Generate the initramfs:
mkinitcpio -o linux
Adapt your GRUB_CMDLINE_LINUX in /etc/default/grub and make sure that you have the following:
nano /etc/default/grub
# GRUB_CMDLINE_LINUX="cryptdevice=UUID={UUID_of_vda3}:vda3_crypt cryptdevice2=UUID={UUID_of_vdb3}:vdb3_crypt"
GRUB_ENABLE_CRYPTODISK=y
Step 5: Add cronjob for scrub
crontab -e
#Add the following line to your crontab
#0 12 * * * /bin/btrfs scrub start /
#Do a manual scrub if you like
btrfs scrub start /
btrfs scrub status
sudo btrfs device stats /
Step 6: Reboot and hope for the best
Note that at boot you insert your password for the first luks partition first and then for the second one to decrypt /boot and close it again, however the keyfiles are then used to decrypt / on both luks paritions. If you want to have only one pass-phrase, you should put /boot on its own luks1-encrypted partition without RAID1.
Hope that helps 