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:
lsblk
Create 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: w
Create 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 cryptsetup
Set Up LUKS Encryption:
cryptsetup luksFormat /dev/md0
Open the Encrypted Device:
cryptsetup open /dev/md0 cryptarray
5. Create Filesystems
Format EFI System Partition (ESP):
mkfs.fat -F32 /dev/sda1
Format the Encrypted RAID Array:
mkfs.ext4 /dev/mapper/cryptarray
6. Mount Filesystems
Mount the Encrypted RAID Array:
mount /dev/mapper/cryptarray /mnt
Create 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-firmware
Generate fstab:
genfstab -U /mnt >> /mnt/etc/fstab
8. Chroot and Configure the System
Chroot into the new system:
arch-chroot /mnt
Set Time Zone:
ln -sf /usr/share/zoneinfo/Region/City /etc/localtime hwclock --systohc
Locale Configuration:
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen locale-gen echo "LANG=en_US.UTF-8" > /etc/locale.conf
Network Configuration:
echo "myhostname" > /etc/hostname echo "127.0.1.1 myhostname.localdomain myhostname" >> /etc/hosts
Set Root Password:
passwd
9. Configure Initramfs for LUKS and RAID
Edit
/etc/mkinitcpio.conf
to includeblock
,mdadm_udev
,encrypt
, andfilesystems
hooks:nano /etc/mkinitcpio.conf
Modify the
HOOKS
line: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 install
Create a loader configuration file:
mkdir -p /boot/loader/ nano /boot/loader/loader.conf
Add the following lines to
loader.conf
:default arch timeout 5 editor 0
Create a boot entry:
mkdir -p /boot/loader/entries/ nano /boot/loader/entries/arch.conf
Add 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 rw
Replace the
UUID
part 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.