If you want to encrypt your SSDs in a RAID-0 setup with systemd-boot, you will use LUKS (Linux Unified Key Setup) to encrypt the partitions. Here is a detailed guide on how to do this:
Prerequisites
Make sure you have followed the steps up to creating partitions and have mdadm installed.
Step-by-Step Guide
1. Prepare the Disks for Encryption
Identify Disks:
lsblkCreate GPT Partition Tables on each SSD (
/dev/sda,/dev/sdb,/dev/sdc):gdisk /dev/sda # Command: o (create a new GPT partition table) # Command: w (write changes and exit) gdisk /dev/sdb # Repeat the same steps gdisk /dev/sdc # Repeat the same steps
2. Create Partitions
Create EFI System Partition (ESP) on the first SSD (
/dev/sda):gdisk /dev/sda # Command: n (new partition) # Partition number: 1 # First sector: default # Last sector: +512M # Hex code or GUID: ef00 # Write changes # Command: wCreate RAID Partitions on all SSDs (
/dev/sda,/dev/sdb,/dev/sdc):gdisk /dev/sda # Command: n (new partition) # Partition number: 2 # First sector: default # Last sector: default (remaining space) # Hex code or GUID: fd00 # Write changes # Command: w # Repeat the same steps for /dev/sdb and /dev/sdc
3. Set Up RAID-0
- Create RAID-0 Array:
mdadm --create --verbose /dev/md0 --level=0 --raid-devices=3 /dev/sda2 /dev/sdb2 /dev/sdc2
4. Encrypt the RAID Array with LUKS
Install cryptsetup:
pacman -Sy cryptsetupSet Up LUKS Encryption:
cryptsetup luksFormat /dev/md0Open the Encrypted Device:
cryptsetup open /dev/md0 cryptarray
5. Create Filesystems
Format EFI System Partition (ESP):
mkfs.fat -F32 /dev/sda1Format the Encrypted RAID Array:
mkfs.ext4 /dev/mapper/cryptarray
6. Mount Filesystems
Mount the Encrypted RAID Array:
mount /dev/mapper/cryptarray /mntCreate and Mount ESP:
mkdir /mnt/boot mount /dev/sda1 /mnt/boot
7. Install Arch Linux Base System
Install Base Packages:
pacstrap /mnt base linux linux-firmwareGenerate fstab:
genfstab -U /mnt >> /mnt/etc/fstab
8. Chroot and Configure the System
Chroot into the new system:
arch-chroot /mntSet Time Zone:
ln -sf /usr/share/zoneinfo/Region/City /etc/localtime hwclock --systohcLocale Configuration:
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen locale-gen echo "LANG=en_US.UTF-8" > /etc/locale.confNetwork Configuration:
echo "myhostname" > /etc/hostname echo "127.0.1.1 myhostname.localdomain myhostname" >> /etc/hostsSet Root Password:
passwd
9. Configure Initramfs for LUKS and RAID
Edit
/etc/mkinitcpio.confto includeblock,mdadm_udev,encrypt, andfilesystemshooks:nano /etc/mkinitcpio.confModify the
HOOKSline:HOOKS="base udev autodetect modconf block mdadm_udev encrypt filesystems keyboard fsck"Rebuild initramfs:
mkinitcpio -P
10. Install and Configure systemd-boot
Install
systemd-boot:bootctl installCreate a loader configuration file:
mkdir -p /boot/loader/ nano /boot/loader/loader.confAdd the following lines to
loader.conf:default arch timeout 5 editor 0Create a boot entry:
mkdir -p /boot/loader/entries/ nano /boot/loader/entries/arch.confAdd the following lines to
arch.conf:title Arch Linux linux /vmlinuz-linux initrd /initramfs-linux.img options cryptdevice=UUID=$(blkid -s UUID -o value /dev/md0):cryptarray root=/dev/mapper/cryptarray rwReplace the
UUIDpart with the actual UUID of/dev/md0:blkid /dev/md0
11. Reboot
- Exit Chroot and Unmount:
exit umount -R /mnt reboot
Remove the USB drive and boot into your new Arch Linux installation. You should be prompted to enter your LUKS passphrase to unlock the RAID-0 array. If everything is configured correctly, systemd-boot will load Arch Linux from your encrypted RAID-0 setup.