User Tools

Site Tools


computing:btrfsreminders

This is an old revision of the document!


Introduction This tutorial is for Debian users that want to create a JBOD pool using BTRFS subvolumes and its RAID10 equivalent. These types of setups are common and helpful for virtualization environments and hosting multiple services, either for serious home hobbyist use and/or small business level production. These approaches are not designed for enterprise or large-scale production.

Overview of setups Encrypting the home partition is essential because it ensures that the pool key is never directly exposed; its behind LUKS on the boot volume and the sysadmin keeps this credential stored in KeePassXC offsite. Thus, the physical layer is protected by LUKS with integrity. As for Pam's mounting utilities, I use this method because it allows for easy remote reboot as there is no need to enter an FDE key in the post-BIOS FDE splash and/or require you to log in to IPMI each time. Instead, you encrypt home and then unlock that in a screen session after remote reboot with screen then su - user - after that, detach from the session with ctrl-d. In short, this method provides two advantages, namely, a secure LUKS-encrypted location for keys/credentials that's not exposed if a physical compromise takes place, and using built-in pam and simple UNIX login infra to avoid cumbersome BIOS/IPMI-level FDE unlocking after reboot. Let's install btrfs, LUKS, and identify your hard drives:

sudo apt-get install cryptsetup libpam-mount btrfs*
ls -lah /dev/disk/by-id/

This installs the required packages and provides you the blkid location/mountpoint for your hard drives. You can also use blkid but I find ls to be easier here tbh. After identifying your JBOD drives, do something like:

dd if=/dev/random of=/home/user/vm.key bs=1 count=32
dd if=/dev/random of=/home/user/wh.key bs=1 count=32
cryptsetup luksFormat /dev/disk/by-id/scsi-35002538a98416870 --key-file /home/user/.unlock/vm.key --type luks2 --cipher aes-xts-plain64 --key-size 512 --pbkdf argon2id --pbkdf-memory 4194304 --pbkdf-parallel 4 --iter-time 4000 --sector-size 4096 --use-random
cryptsetup luksFormat /dev/disk/by-id/scsi-35002538a98356f30 --key-file /home/user/.unlock/vm.key --type luks2 --cipher aes-xts-plain64 --key-size 512 --pbkdf argon2id --pbkdf-memory 4194304 --pbkdf-parallel 4 --iter-time 4000 --sector-size 4096 --use-random
cryptsetup luksFormat /dev/disk/by-id/scsi-35002538a983571d0 --key-file /home/user/.unlock/vm.key --type luks2 --cipher aes-xts-plain64 --key-size 512 --pbkdf argon2id --pbkdf-memory 4194304 --pbkdf-parallel 4 --iter-time 4000 --sector-size 4096 --use-random
cryptsetup luksFormat /dev/disk/by-id/scsi-35002538a98356590 --key-file /home/user/.unlock/vm.key --type luks2 --cipher aes-xts-plain64 --key-size 512 --pbkdf argon2id --pbkdf-memory 4194304 --pbkdf-parallel 4 --iter-time 4000 --sector-size 4096 --use-random
cryptsetup luksFormat /dev/disk/by-id/scsi-35002538a0840a300 --key-file /home/user/.unlock/vm.key --type luks2 --cipher aes-xts-plain64 --key-size 512 --pbkdf argon2id --pbkdf-memory 4194304 --pbkdf-parallel 4 --iter-time 4000 --sector-size 4096 --use-random
cryptsetup luksFormat /dev/disk/by-id/scsi-35002538a98356500 --key-file /home/user/.unlock/vm.key --type luks2 --cipher aes-xts-plain64 --key-size 512 --pbkdf argon2id --pbkdf-memory 4194304 --pbkdf-parallel 4 --iter-time 4000 --sector-size 4096 --use-random
cryptsetup luksFormat /dev/disk/by-id/scsi-35002538a084065d0 --key-file /home/user/.unlock/vm.key --type luks2 --cipher aes-xts-plain64 --key-size 512 --pbkdf argon2id --pbkdf-memory 4194304 --pbkdf-parallel 4 --iter-time 4000 --sector-size 4096 --use-random
cryptsetup luksFormat /dev/disk/by-id/scsi-35002538a98357220 --key-file /home/user/.unlock/vm.key --type luks2 --cipher aes-xts-plain64 --key-size 512 --pbkdf argon2id --pbkdf-memory 4194304 --pbkdf-parallel 4 --iter-time 4000 --sector-size 4096 --use-random
cryptsetup luksFormat /dev/disk/by-id/scsi-35000c500d775df03 --key-file /home/user/.unlock/wh.key --type luks2 --cipher aes-xts-plain64 --key-size 512 --pbkdf argon2id --pbkdf-memory 4194304 --pbkdf-parallel 4 --iter-time 4000 --sector-size 4096 --use-random
cryptsetup luksFormat /dev/disk/by-id/scsi-35000c500d7694517 --key-file /home/user/.unlock/wh.key --type luks2 --cipher aes-xts-plain64 --key-size 512 --pbkdf argon2id --pbkdf-memory 4194304 --pbkdf-parallel 4 --iter-time 4000 --sector-size 4096 --use-random
cryptsetup luksFormat /dev/disk/by-id/scsi-35000c500d7771943 --key-file /home/user/.unlock/wh.key --type luks2 --cipher aes-xts-plain64 --key-size 512 --pbkdf argon2id --pbkdf-memory 4194304 --pbkdf-parallel 4 --iter-time 4000 --sector-size 4096 --use-random
cryptsetup luksFormat /dev/disk/by-id/scsi-35000c500cb1689e3 --key-file /home/user/.unlock/wh.key --type luks2 --cipher aes-xts-plain64 --key-size 512 --pbkdf argon2id --pbkdf-memory 4194304 --pbkdf-parallel 4 --iter-time 4000 --sector-size 4096 --use-random

After you create the crypts on the hard drive and specify the key, you need to mount the volume and assign the unique blkid a dedicated/unique shortname for its mountpoint. You do this as follows:

cryptsetup luksOpen /dev/disk/by-id/scsi-35002538a98416870 ssd1 –key-file /home/user/.unlock/vm.key cryptsetup luksOpen /dev/disk/by-id/scsi-35002538a98356f30 ssd2 –key-file /home/user/.unlock/vm.key cryptsetup luksOpen /dev/disk/by-id/scsi-35002538a983571d0 ssd3 –key-file /home/user/.unlock/vm.key cryptsetup luksOpen /dev/disk/by-id/scsi-35002538a98356590 ssd4 –key-file /home/user/.unlock/vm.key cryptsetup luksOpen /dev/disk/by-id/scsi-35002538a0840a300 ssd5 –key-file /home/user/.unlock/vm.key cryptsetup luksOpen /dev/disk/by-id/scsi-35002538a98356500 ssd6 –key-file /home/user/.unlock/vm.key cryptsetup luksOpen /dev/disk/by-id/scsi-35002538a084065d0 ssd7 –key-file /home/user/.unlock/vm.key cryptsetup luksOpen /dev/disk/by-id/scsi-35002538a98357220 ssd8 –key-file /home/user/.unlock/vm.key cryptsetup luksOpen /dev/disk/by-id/scsi-35000c500d775df03 hdd1 –key-file /home/user/.unlock/wh.key cryptsetup luksOpen /dev/disk/by-id/scsi-35000c500d7694517 hdd2 –key-file /home/user/.unlock/wh.key cryptsetup luksOpen /dev/disk/by-id/scsi-35000c500d7771943 hdd3 –key-file /home/user/.unlock/wh.key cryptsetup luksOpen /dev/disk/by-id/scsi-35000c500cb1689e3 hdd4 –key-file /home/user/.unlock/wh.key

computing/btrfsreminders.1770495531.txt.gz · Last modified: by oemb1905