feat(encryption): implement phase 2 with btrfs and optional LUKS encryption using Argon2id
- commit
- 59830f292837e471bf955aa3e1b7e26ead1764f1
- author
- bnema · · 2025-10-19 07:27 UTC
- parent
- dc1caf5
- signature
- unsigned
6 files · +153 -30
M README.md +20 -13
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | 7 | ✅ **Phase 0: Core Infrastructure - COMPLETE** | |
| 8 | 8 | ✅ **Phase 1: Barebone Installer - Basic - COMPLETE** | |
| 9 | + | ✅ **Phase 2: Add btrfs + LUKS Encryption - COMPLETE** | |
| 9 | 10 | ||
| 10 | 11 | ### Completed | |
| 11 | 12 | - ✅ Project structure created | |
| @@ -15,11 +16,14 @@ | |||
| 15 | 16 | - ✅ Logo designed | |
| 16 | 17 | - ✅ System guards (vanilla Arch, UEFI, x86_64, Secure Boot checks) | |
| 17 | 18 | - ✅ Bootloader selection (systemd-boot or limine) | |
| 18 | - | - ✅ Auto-partitioning (GPT, EFI + root with ext4) | |
| 19 | + | - ✅ Auto-partitioning (GPT, EFI + root) | |
| 19 | 20 | - ✅ Base system installation (pacstrap + fstab) | |
| 20 | 21 | - ✅ System configuration (timezone, locale, hostname, user creation) | |
| 21 | 22 | - ✅ Network configuration (systemd-networkd + iwd) | |
| 22 | 23 | - ✅ Bootloader installation (systemd-boot with boot entries) | |
| 24 | + | - ✅ btrfs filesystem with subvolumes (@ for root, @home for home) | |
| 25 | + | - ✅ LUKS encryption with Argon2id (optional, 2000ms iteration) | |
| 26 | + | - ✅ Encrypted boot support (mkinitcpio hooks) | |
| 23 | 27 | ||
| 24 | 28 | ### Project Structure | |
| 25 | 29 | ``` | |
| @@ -123,12 +127,15 @@ sudo ./install.sh | |||
| 123 | 127 | ||
| 124 | 128 | **What the installer does:** | |
| 125 | 129 | 1. Validates system (vanilla Arch ISO, UEFI, x86_64) | |
| 126 | - | 2. Selects installation disk (auto-partitions with GPT) | |
| 127 | - | 3. Formats partitions (FAT32 EFI + ext4 root) | |
| 128 | - | 4. Installs ~15 base packages with pacstrap | |
| 129 | - | 5. Configures system (timezone, locale, hostname, user) | |
| 130 | - | 6. Installs systemd-boot bootloader | |
| 131 | - | 7. Creates bootable minimal Arch system | |
| 130 | + | 2. Asks for bootloader preference (systemd-boot or limine) | |
| 131 | + | 3. Asks for encryption preference (optional LUKS with Argon2id) | |
| 132 | + | 4. Selects installation disk (auto-partitions with GPT) | |
| 133 | + | 5. Formats partitions (FAT32 EFI + btrfs root with optional LUKS) | |
| 134 | + | 6. Creates btrfs subvolumes (@ for root, @home for home) | |
| 135 | + | 7. Installs ~15 base packages with pacstrap (+ cryptsetup if encrypted) | |
| 136 | + | 8. Configures system (timezone, locale, hostname, user) | |
| 137 | + | 9. Installs systemd-boot bootloader (with encryption support if enabled) | |
| 138 | + | 10. Creates bootable minimal Arch system | |
| 132 | 139 | ||
| 133 | 140 | ## Environment Variables | |
| 134 | 141 | ||
| @@ -138,12 +145,12 @@ sudo ./install.sh | |||
| 138 | 145 | ||
| 139 | 146 | ## Next Steps | |
| 140 | 147 | ||
| 141 | - | **Phase 2: Add btrfs + LUKS Encryption** (Week 2-3) | |
| 142 | - | - [ ] Replace ext4 with btrfs filesystem | |
| 143 | - | - [ ] Add LUKS full-disk encryption option | |
| 144 | - | - [ ] Configure Argon2id with 2000ms iteration time | |
| 145 | - | - [ ] Create btrfs subvolumes (@ for root, @home for home) | |
| 146 | - | - [ ] Update bootloader for encrypted boot | |
| 148 | + | **Phase 3: Add Limine Bootloader Option** (Week 3) | |
| 149 | + | - [ ] Support Limine as alternative to systemd-boot | |
| 150 | + | - [ ] Create install/boot/limine.sh script | |
| 151 | + | - [ ] Configure limine.conf for UEFI | |
| 152 | + | - [ ] Add encryption support for Limine | |
| 153 | + | - [ ] Test both bootloaders with encryption | |
| 147 | 154 | ||
| 148 | 155 | ## Reference | |
| 149 | 156 | ||
| @@ -6,6 +6,7 @@ | |||||
| 6 | 6 | ||||
| 7 | ✅ **Phase 0: Core Infrastructure - COMPLETE** | 7 | ✅ **Phase 0: Core Infrastructure - COMPLETE** | ||
| 8 | ✅ **Phase 1: Barebone Installer - Basic - COMPLETE** | 8 | ✅ **Phase 1: Barebone Installer - Basic - COMPLETE** | ||
| 9 | + | ✅ **Phase 2: Add btrfs + LUKS Encryption - COMPLETE** | |||
| 9 | 10 | ||||
| 10 | ### Completed | 11 | ### Completed | ||
| 11 | - ✅ Project structure created | 12 | - ✅ Project structure created | ||
| @@ -15,11 +16,14 @@ | |||||
| 15 | - ✅ Logo designed | 16 | - ✅ Logo designed | ||
| 16 | - ✅ System guards (vanilla Arch, UEFI, x86_64, Secure Boot checks) | 17 | - ✅ System guards (vanilla Arch, UEFI, x86_64, Secure Boot checks) | ||
| 17 | - ✅ Bootloader selection (systemd-boot or limine) | 18 | - ✅ Bootloader selection (systemd-boot or limine) | ||
| 18 | - | - ✅ Auto-partitioning (GPT, EFI + root with ext4) | 19 | + | - ✅ Auto-partitioning (GPT, EFI + root) |
| 19 | - ✅ Base system installation (pacstrap + fstab) | 20 | - ✅ Base system installation (pacstrap + fstab) | ||
| 20 | - ✅ System configuration (timezone, locale, hostname, user creation) | 21 | - ✅ System configuration (timezone, locale, hostname, user creation) | ||
| 21 | - ✅ Network configuration (systemd-networkd + iwd) | 22 | - ✅ Network configuration (systemd-networkd + iwd) | ||
| 22 | - ✅ Bootloader installation (systemd-boot with boot entries) | 23 | - ✅ Bootloader installation (systemd-boot with boot entries) | ||
| 24 | + | - ✅ btrfs filesystem with subvolumes (@ for root, @home for home) | |||
| 25 | + | - ✅ LUKS encryption with Argon2id (optional, 2000ms iteration) | |||
| 26 | + | - ✅ Encrypted boot support (mkinitcpio hooks) | |||
| 23 | 27 | ||||
| 24 | ### Project Structure | 28 | ### Project Structure | ||
| 25 | ``` | 29 | ``` | ||
| @@ -123,12 +127,15 @@ sudo ./install.sh | |||||
| 123 | 127 | ||||
| 124 | **What the installer does:** | 128 | **What the installer does:** | ||
| 125 | 1. Validates system (vanilla Arch ISO, UEFI, x86_64) | 129 | 1. Validates system (vanilla Arch ISO, UEFI, x86_64) | ||
| 126 | - | 2. Selects installation disk (auto-partitions with GPT) | 130 | + | 2. Asks for bootloader preference (systemd-boot or limine) |
| 127 | - | 3. Formats partitions (FAT32 EFI + ext4 root) | 131 | + | 3. Asks for encryption preference (optional LUKS with Argon2id) |
| 128 | - | 4. Installs ~15 base packages with pacstrap | 132 | + | 4. Selects installation disk (auto-partitions with GPT) |
| 129 | - | 5. Configures system (timezone, locale, hostname, user) | 133 | + | 5. Formats partitions (FAT32 EFI + btrfs root with optional LUKS) |
| 130 | - | 6. Installs systemd-boot bootloader | 134 | + | 6. Creates btrfs subvolumes (@ for root, @home for home) |
| 131 | - | 7. Creates bootable minimal Arch system | 135 | + | 7. Installs ~15 base packages with pacstrap (+ cryptsetup if encrypted) |
| 136 | + | 8. Configures system (timezone, locale, hostname, user) | |||
| 137 | + | 9. Installs systemd-boot bootloader (with encryption support if enabled) | |||
| 138 | + | 10. Creates bootable minimal Arch system | |||
| 132 | 139 | ||||
| 133 | ## Environment Variables | 140 | ## Environment Variables | ||
| 134 | 141 | ||||
| @@ -138,12 +145,12 @@ sudo ./install.sh | |||||
| 138 | 145 | ||||
| 139 | ## Next Steps | 146 | ## Next Steps | ||
| 140 | 147 | ||||
| 141 | - | **Phase 2: Add btrfs + LUKS Encryption** (Week 2-3) | 148 | + | **Phase 3: Add Limine Bootloader Option** (Week 3) |
| 142 | - | - [ ] Replace ext4 with btrfs filesystem | 149 | + | - [ ] Support Limine as alternative to systemd-boot |
| 143 | - | - [ ] Add LUKS full-disk encryption option | 150 | + | - [ ] Create install/boot/limine.sh script |
| 144 | - | - [ ] Configure Argon2id with 2000ms iteration time | 151 | + | - [ ] Configure limine.conf for UEFI |
| 145 | - | - [ ] Create btrfs subvolumes (@ for root, @home for home) | 152 | + | - [ ] Add encryption support for Limine |
| 146 | - | - [ ] Update bootloader for encrypted boot | 153 | + | - [ ] Test both bootloaders with encryption |
| 147 | 154 | ||||
| 148 | ## Reference | 155 | ## Reference | ||
| 149 | 156 | ||||
M install/base/pacstrap.sh +6 -0
| @@ -7,6 +7,12 @@ gum style --padding "0 0 1 $PADDING_LEFT" "This may take a few minutes..." | |||
| 7 | 7 | # Read barebone package list | |
| 8 | 8 | mapfile -t packages < <(grep -v '^#' "$ARCHUP_INSTALL/presets/barebone.packages" | grep -v '^$') | |
| 9 | 9 | ||
| 10 | + | # Add cryptsetup if encryption is enabled | |
| 11 | + | if [ "$ARCHUP_ENCRYPTION" = "enabled" ]; then | |
| 12 | + | packages+=("cryptsetup") | |
| 13 | + | echo "Adding cryptsetup for LUKS encryption" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 14 | + | fi | |
| 15 | + | ||
| 10 | 16 | # Install base system | |
| 11 | 17 | pacstrap /mnt "${packages[@]}" | |
| 12 | 18 | ||
| @@ -7,6 +7,12 @@ gum style --padding "0 0 1 $PADDING_LEFT" "This may take a few minutes..." | |||||
| 7 | # Read barebone package list | 7 | # Read barebone package list | ||
| 8 | mapfile -t packages < <(grep -v '^#' "$ARCHUP_INSTALL/presets/barebone.packages" | grep -v '^$') | 8 | mapfile -t packages < <(grep -v '^#' "$ARCHUP_INSTALL/presets/barebone.packages" | grep -v '^$') | ||
| 9 | 9 | ||||
| 10 | + | # Add cryptsetup if encryption is enabled | |||
| 11 | + | if [ "$ARCHUP_ENCRYPTION" = "enabled" ]; then | |||
| 12 | + | packages+=("cryptsetup") | |||
| 13 | + | echo "Adding cryptsetup for LUKS encryption" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |||
| 14 | + | fi | |||
| 15 | + | ||||
| 10 | # Install base system | 16 | # Install base system | ||
| 11 | pacstrap /mnt "${packages[@]}" | 17 | pacstrap /mnt "${packages[@]}" | ||
| 12 | 18 | ||||
M install/boot/systemd-boot.sh +30 -5
| @@ -6,8 +6,29 @@ gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Installing systemd-boo | |||
| 6 | 6 | # Install systemd-boot | |
| 7 | 7 | arch-chroot /mnt bootctl install | |
| 8 | 8 | ||
| 9 | - | # Get root partition UUID | |
| 10 | - | ROOT_UUID=$(blkid -s UUID -o value "$ARCHUP_ROOT_PART") | |
| 9 | + | # Determine root device UUID | |
| 10 | + | if [ "$ARCHUP_ENCRYPTION" = "enabled" ]; then | |
| 11 | + | # For encrypted setups, we need the root partition UUID (before LUKS) | |
| 12 | + | ROOT_UUID=$(blkid -s UUID -o value "$ARCHUP_ROOT_PART") | |
| 13 | + | ||
| 14 | + | # Update mkinitcpio.conf to add encrypt hook | |
| 15 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Configuring initramfs for encryption..." | |
| 16 | + | ||
| 17 | + | # Add encrypt hook before filesystems hook | |
| 18 | + | sed -i 's/^HOOKS=.*/HOOKS=(base udev autodetect microcode modconf kms keyboard keymap consolefont block encrypt filesystems fsck)/' /mnt/etc/mkinitcpio.conf | |
| 19 | + | ||
| 20 | + | # Regenerate initramfs | |
| 21 | + | arch-chroot /mnt mkinitcpio -P | |
| 22 | + | ||
| 23 | + | echo "Updated mkinitcpio.conf with encrypt hook" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 24 | + | ||
| 25 | + | # Kernel parameters for encrypted boot | |
| 26 | + | KERNEL_PARAMS="cryptdevice=UUID=$ROOT_UUID:cryptroot root=/dev/mapper/cryptroot rootflags=subvol=@ rw" | |
| 27 | + | else | |
| 28 | + | # For non-encrypted setups, use the root partition UUID directly | |
| 29 | + | ROOT_UUID=$(blkid -s UUID -o value "$ARCHUP_ROOT_PART") | |
| 30 | + | KERNEL_PARAMS="root=UUID=$ROOT_UUID rootflags=subvol=@ rw" | |
| 31 | + | fi | |
| 11 | 32 | ||
| 12 | 33 | # Create loader configuration | |
| 13 | 34 | cat > /mnt/boot/loader/loader.conf <<EOF | |
| @@ -22,7 +43,7 @@ cat > /mnt/boot/loader/entries/arch.conf <<EOF | |||
| 22 | 43 | title Arch Linux | |
| 23 | 44 | linux /vmlinuz-linux | |
| 24 | 45 | initrd /initramfs-linux.img | |
| 25 | - | options root=UUID=$ROOT_UUID rw | |
| 46 | + | options $KERNEL_PARAMS | |
| 26 | 47 | EOF | |
| 27 | 48 | ||
| 28 | 49 | # Create fallback boot entry | |
| @@ -30,9 +51,13 @@ cat > /mnt/boot/loader/entries/arch-fallback.conf <<EOF | |||
| 30 | 51 | title Arch Linux (fallback) | |
| 31 | 52 | linux /vmlinuz-linux | |
| 32 | 53 | initrd /initramfs-linux-fallback.img | |
| 33 | - | options root=UUID=$ROOT_UUID rw | |
| 54 | + | options $KERNEL_PARAMS | |
| 34 | 55 | EOF | |
| 35 | 56 | ||
| 36 | 57 | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "✓ systemd-boot installed and configured" | |
| 37 | 58 | ||
| 38 | - | echo "Installed systemd-boot with root UUID: $ROOT_UUID" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 59 | + | if [ "$ARCHUP_ENCRYPTION" = "enabled" ]; then | |
| 60 | + | echo "Installed systemd-boot with encrypted root (UUID: $ROOT_UUID)" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 61 | + | else | |
| 62 | + | echo "Installed systemd-boot with root UUID: $ROOT_UUID" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 63 | + | fi | |
| @@ -6,8 +6,29 @@ gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Installing systemd-boo | |||||
| 6 | # Install systemd-boot | 6 | # Install systemd-boot | ||
| 7 | arch-chroot /mnt bootctl install | 7 | arch-chroot /mnt bootctl install | ||
| 8 | 8 | ||||
| 9 | - | # Get root partition UUID | 9 | + | # Determine root device UUID |
| 10 | - | ROOT_UUID=$(blkid -s UUID -o value "$ARCHUP_ROOT_PART") | 10 | + | if [ "$ARCHUP_ENCRYPTION" = "enabled" ]; then |
| 11 | + | # For encrypted setups, we need the root partition UUID (before LUKS) | |||
| 12 | + | ROOT_UUID=$(blkid -s UUID -o value "$ARCHUP_ROOT_PART") | |||
| 13 | + | ||||
| 14 | + | # Update mkinitcpio.conf to add encrypt hook | |||
| 15 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Configuring initramfs for encryption..." | |||
| 16 | + | ||||
| 17 | + | # Add encrypt hook before filesystems hook | |||
| 18 | + | sed -i 's/^HOOKS=.*/HOOKS=(base udev autodetect microcode modconf kms keyboard keymap consolefont block encrypt filesystems fsck)/' /mnt/etc/mkinitcpio.conf | |||
| 19 | + | ||||
| 20 | + | # Regenerate initramfs | |||
| 21 | + | arch-chroot /mnt mkinitcpio -P | |||
| 22 | + | ||||
| 23 | + | echo "Updated mkinitcpio.conf with encrypt hook" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |||
| 24 | + | ||||
| 25 | + | # Kernel parameters for encrypted boot | |||
| 26 | + | KERNEL_PARAMS="cryptdevice=UUID=$ROOT_UUID:cryptroot root=/dev/mapper/cryptroot rootflags=subvol=@ rw" | |||
| 27 | + | else | |||
| 28 | + | # For non-encrypted setups, use the root partition UUID directly | |||
| 29 | + | ROOT_UUID=$(blkid -s UUID -o value "$ARCHUP_ROOT_PART") | |||
| 30 | + | KERNEL_PARAMS="root=UUID=$ROOT_UUID rootflags=subvol=@ rw" | |||
| 31 | + | fi | |||
| 11 | 32 | ||||
| 12 | # Create loader configuration | 33 | # Create loader configuration | ||
| 13 | cat > /mnt/boot/loader/loader.conf <<EOF | 34 | cat > /mnt/boot/loader/loader.conf <<EOF | ||
| @@ -22,7 +43,7 @@ cat > /mnt/boot/loader/entries/arch.conf <<EOF | |||||
| 22 | title Arch Linux | 43 | title Arch Linux | ||
| 23 | linux /vmlinuz-linux | 44 | linux /vmlinuz-linux | ||
| 24 | initrd /initramfs-linux.img | 45 | initrd /initramfs-linux.img | ||
| 25 | - | options root=UUID=$ROOT_UUID rw | 46 | + | options $KERNEL_PARAMS |
| 26 | EOF | 47 | EOF | ||
| 27 | 48 | ||||
| 28 | # Create fallback boot entry | 49 | # Create fallback boot entry | ||
| @@ -30,9 +51,13 @@ cat > /mnt/boot/loader/entries/arch-fallback.conf <<EOF | |||||
| 30 | title Arch Linux (fallback) | 51 | title Arch Linux (fallback) | ||
| 31 | linux /vmlinuz-linux | 52 | linux /vmlinuz-linux | ||
| 32 | initrd /initramfs-linux-fallback.img | 53 | initrd /initramfs-linux-fallback.img | ||
| 33 | - | options root=UUID=$ROOT_UUID rw | 54 | + | options $KERNEL_PARAMS |
| 34 | EOF | 55 | EOF | ||
| 35 | 56 | ||||
| 36 | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "✓ systemd-boot installed and configured" | 57 | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "✓ systemd-boot installed and configured" | ||
| 37 | 58 | ||||
| 38 | - | echo "Installed systemd-boot with root UUID: $ROOT_UUID" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | 59 | + | if [ "$ARCHUP_ENCRYPTION" = "enabled" ]; then |
| 60 | + | echo "Installed systemd-boot with encrypted root (UUID: $ROOT_UUID)" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |||
| 61 | + | else | |||
| 62 | + | echo "Installed systemd-boot with root UUID: $ROOT_UUID" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |||
| 63 | + | fi | |||
M install/partitioning/format.sh +61 -6
| @@ -1,15 +1,70 @@ | |||
| 1 | 1 | #!/bin/bash | |
| 2 | - | # Format partitions (ext4 for Phase 1, btrfs comes in Phase 2) | |
| 2 | + | # Format partitions with btrfs and optional LUKS encryption | |
| 3 | 3 | ||
| 4 | 4 | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Formatting partitions..." | |
| 5 | 5 | ||
| 6 | 6 | # Format EFI partition as FAT32 | |
| 7 | 7 | mkfs.fat -F32 -n EFI "$ARCHUP_EFI_PART" | |
| 8 | + | echo "Formatted $ARCHUP_EFI_PART as FAT32" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 8 | 9 | ||
| 9 | - | # Format root partition as ext4 | |
| 10 | - | mkfs.ext4 -F -L ROOT "$ARCHUP_ROOT_PART" | |
| 10 | + | # Handle root partition - with or without encryption | |
| 11 | + | if [ "$ARCHUP_ENCRYPTION" = "enabled" ]; then | |
| 12 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Setting up LUKS encryption..." | |
| 11 | 13 | ||
| 12 | - | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "✓ Partitions formatted" | |
| 14 | + | # Prompt for encryption password | |
| 15 | + | while true; do | |
| 16 | + | LUKS_PASSWORD=$(gum input --password --placeholder "Enter encryption password" --padding "0 0 0 $PADDING_LEFT") | |
| 17 | + | LUKS_PASSWORD_CONFIRM=$(gum input --password --placeholder "Confirm encryption password" --padding "0 0 0 $PADDING_LEFT") | |
| 13 | 18 | ||
| 14 | - | echo "Formatted $ARCHUP_EFI_PART as FAT32" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 15 | - | echo "Formatted $ARCHUP_ROOT_PART as ext4" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 19 | + | if [ "$LUKS_PASSWORD" = "$LUKS_PASSWORD_CONFIRM" ]; then | |
| 20 | + | break | |
| 21 | + | else | |
| 22 | + | gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "Passwords do not match. Try again." | |
| 23 | + | fi | |
| 24 | + | done | |
| 25 | + | ||
| 26 | + | # Setup LUKS with Argon2id and 2000ms iteration time | |
| 27 | + | echo "$LUKS_PASSWORD" | cryptsetup luksFormat \ | |
| 28 | + | --type luks2 \ | |
| 29 | + | --pbkdf argon2id \ | |
| 30 | + | --iter-time 2000 \ | |
| 31 | + | --label ARCHUP_LUKS \ | |
| 32 | + | "$ARCHUP_ROOT_PART" | |
| 33 | + | ||
| 34 | + | # Open the encrypted container | |
| 35 | + | echo "$LUKS_PASSWORD" | cryptsetup open "$ARCHUP_ROOT_PART" cryptroot | |
| 36 | + | ||
| 37 | + | # Export the mapped device path | |
| 38 | + | export ARCHUP_CRYPT_ROOT="/dev/mapper/cryptroot" | |
| 39 | + | ||
| 40 | + | # Format the encrypted container with btrfs | |
| 41 | + | mkfs.btrfs -f -L ROOT "$ARCHUP_CRYPT_ROOT" | |
| 42 | + | ||
| 43 | + | echo "Created LUKS container on $ARCHUP_ROOT_PART" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 44 | + | echo "Formatted $ARCHUP_CRYPT_ROOT as btrfs" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 45 | + | ||
| 46 | + | # Mount temporarily to create subvolumes | |
| 47 | + | mount "$ARCHUP_CRYPT_ROOT" /mnt | |
| 48 | + | ||
| 49 | + | else | |
| 50 | + | # No encryption - format directly with btrfs | |
| 51 | + | mkfs.btrfs -f -L ROOT "$ARCHUP_ROOT_PART" | |
| 52 | + | echo "Formatted $ARCHUP_ROOT_PART as btrfs" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 53 | + | ||
| 54 | + | # Mount temporarily to create subvolumes | |
| 55 | + | mount "$ARCHUP_ROOT_PART" /mnt | |
| 56 | + | fi | |
| 57 | + | ||
| 58 | + | # Create btrfs subvolumes | |
| 59 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Creating btrfs subvolumes..." | |
| 60 | + | ||
| 61 | + | btrfs subvolume create /mnt/@ | |
| 62 | + | btrfs subvolume create /mnt/@home | |
| 63 | + | ||
| 64 | + | echo "Created btrfs subvolume: @" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 65 | + | echo "Created btrfs subvolume: @home" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 66 | + | ||
| 67 | + | # Unmount temporary mount | |
| 68 | + | umount /mnt | |
| 69 | + | ||
| 70 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "✓ Partitions formatted and subvolumes created" | |
| @@ -1,15 +1,70 @@ | |||||
| 1 | #!/bin/bash | 1 | #!/bin/bash | ||
| 2 | - | # Format partitions (ext4 for Phase 1, btrfs comes in Phase 2) | 2 | + | # Format partitions with btrfs and optional LUKS encryption |
| 3 | 3 | ||||
| 4 | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Formatting partitions..." | 4 | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Formatting partitions..." | ||
| 5 | 5 | ||||
| 6 | # Format EFI partition as FAT32 | 6 | # Format EFI partition as FAT32 | ||
| 7 | mkfs.fat -F32 -n EFI "$ARCHUP_EFI_PART" | 7 | mkfs.fat -F32 -n EFI "$ARCHUP_EFI_PART" | ||
| 8 | + | echo "Formatted $ARCHUP_EFI_PART as FAT32" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |||
| 8 | 9 | ||||
| 9 | - | # Format root partition as ext4 | 10 | + | # Handle root partition - with or without encryption |
| 10 | - | mkfs.ext4 -F -L ROOT "$ARCHUP_ROOT_PART" | 11 | + | if [ "$ARCHUP_ENCRYPTION" = "enabled" ]; then |
| 12 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Setting up LUKS encryption..." | |||
| 11 | 13 | ||||
| 12 | - | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "✓ Partitions formatted" | 14 | + | # Prompt for encryption password |
| 15 | + | while true; do | |||
| 16 | + | LUKS_PASSWORD=$(gum input --password --placeholder "Enter encryption password" --padding "0 0 0 $PADDING_LEFT") | |||
| 17 | + | LUKS_PASSWORD_CONFIRM=$(gum input --password --placeholder "Confirm encryption password" --padding "0 0 0 $PADDING_LEFT") | |||
| 13 | 18 | ||||
| 14 | - | echo "Formatted $ARCHUP_EFI_PART as FAT32" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | 19 | + | if [ "$LUKS_PASSWORD" = "$LUKS_PASSWORD_CONFIRM" ]; then |
| 15 | - | echo "Formatted $ARCHUP_ROOT_PART as ext4" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | 20 | + | break |
| 21 | + | else | |||
| 22 | + | gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "Passwords do not match. Try again." | |||
| 23 | + | fi | |||
| 24 | + | done | |||
| 25 | + | ||||
| 26 | + | # Setup LUKS with Argon2id and 2000ms iteration time | |||
| 27 | + | echo "$LUKS_PASSWORD" | cryptsetup luksFormat \ | |||
| 28 | + | --type luks2 \ | |||
| 29 | + | --pbkdf argon2id \ | |||
| 30 | + | --iter-time 2000 \ | |||
| 31 | + | --label ARCHUP_LUKS \ | |||
| 32 | + | "$ARCHUP_ROOT_PART" | |||
| 33 | + | ||||
| 34 | + | # Open the encrypted container | |||
| 35 | + | echo "$LUKS_PASSWORD" | cryptsetup open "$ARCHUP_ROOT_PART" cryptroot | |||
| 36 | + | ||||
| 37 | + | # Export the mapped device path | |||
| 38 | + | export ARCHUP_CRYPT_ROOT="/dev/mapper/cryptroot" | |||
| 39 | + | ||||
| 40 | + | # Format the encrypted container with btrfs | |||
| 41 | + | mkfs.btrfs -f -L ROOT "$ARCHUP_CRYPT_ROOT" | |||
| 42 | + | ||||
| 43 | + | echo "Created LUKS container on $ARCHUP_ROOT_PART" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |||
| 44 | + | echo "Formatted $ARCHUP_CRYPT_ROOT as btrfs" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |||
| 45 | + | ||||
| 46 | + | # Mount temporarily to create subvolumes | |||
| 47 | + | mount "$ARCHUP_CRYPT_ROOT" /mnt | |||
| 48 | + | ||||
| 49 | + | else | |||
| 50 | + | # No encryption - format directly with btrfs | |||
| 51 | + | mkfs.btrfs -f -L ROOT "$ARCHUP_ROOT_PART" | |||
| 52 | + | echo "Formatted $ARCHUP_ROOT_PART as btrfs" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |||
| 53 | + | ||||
| 54 | + | # Mount temporarily to create subvolumes | |||
| 55 | + | mount "$ARCHUP_ROOT_PART" /mnt | |||
| 56 | + | fi | |||
| 57 | + | ||||
| 58 | + | # Create btrfs subvolumes | |||
| 59 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Creating btrfs subvolumes..." | |||
| 60 | + | ||||
| 61 | + | btrfs subvolume create /mnt/@ | |||
| 62 | + | btrfs subvolume create /mnt/@home | |||
| 63 | + | ||||
| 64 | + | echo "Created btrfs subvolume: @" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |||
| 65 | + | echo "Created btrfs subvolume: @home" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |||
| 66 | + | ||||
| 67 | + | # Unmount temporary mount | |||
| 68 | + | umount /mnt | |||
| 69 | + | ||||
| 70 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "✓ Partitions formatted and subvolumes created" | |||
M install/partitioning/mount.sh +22 -6
| @@ -1,16 +1,32 @@ | |||
| 1 | 1 | #!/bin/bash | |
| 2 | - | # Mount partitions to /mnt | |
| 2 | + | # Mount btrfs subvolumes to /mnt | |
| 3 | 3 | ||
| 4 | 4 | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Mounting partitions..." | |
| 5 | 5 | ||
| 6 | - | # Mount root partition | |
| 7 | - | mount "$ARCHUP_ROOT_PART" /mnt | |
| 6 | + | # Determine which device to mount (encrypted or not) | |
| 7 | + | if [ "$ARCHUP_ENCRYPTION" = "enabled" ]; then | |
| 8 | + | MOUNT_DEVICE="$ARCHUP_CRYPT_ROOT" | |
| 9 | + | else | |
| 10 | + | MOUNT_DEVICE="$ARCHUP_ROOT_PART" | |
| 11 | + | fi | |
| 12 | + | ||
| 13 | + | # Mount @ subvolume as root with optimal btrfs options | |
| 14 | + | mount -o noatime,compress=zstd,subvol=@ "$MOUNT_DEVICE" /mnt | |
| 15 | + | ||
| 16 | + | echo "Mounted @ subvolume to /mnt" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 17 | + | ||
| 18 | + | # Create home directory | |
| 19 | + | mkdir -p /mnt/home | |
| 20 | + | ||
| 21 | + | # Mount @home subvolume | |
| 22 | + | mount -o noatime,compress=zstd,subvol=@home "$MOUNT_DEVICE" /mnt/home | |
| 23 | + | ||
| 24 | + | echo "Mounted @home subvolume to /mnt/home" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 8 | 25 | ||
| 9 | 26 | # Create and mount EFI directory | |
| 10 | 27 | mkdir -p /mnt/boot | |
| 11 | 28 | mount "$ARCHUP_EFI_PART" /mnt/boot | |
| 12 | 29 | ||
| 13 | - | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "✓ Partitions mounted" | |
| 14 | - | ||
| 15 | - | echo "Mounted $ARCHUP_ROOT_PART to /mnt" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 16 | 30 | echo "Mounted $ARCHUP_EFI_PART to /mnt/boot" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 31 | + | ||
| 32 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "✓ Partitions mounted" | |
| @@ -1,16 +1,32 @@ | |||||
| 1 | #!/bin/bash | 1 | #!/bin/bash | ||
| 2 | - | # Mount partitions to /mnt | 2 | + | # Mount btrfs subvolumes to /mnt |
| 3 | 3 | ||||
| 4 | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Mounting partitions..." | 4 | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Mounting partitions..." | ||
| 5 | 5 | ||||
| 6 | - | # Mount root partition | 6 | + | # Determine which device to mount (encrypted or not) |
| 7 | - | mount "$ARCHUP_ROOT_PART" /mnt | 7 | + | if [ "$ARCHUP_ENCRYPTION" = "enabled" ]; then |
| 8 | + | MOUNT_DEVICE="$ARCHUP_CRYPT_ROOT" | |||
| 9 | + | else | |||
| 10 | + | MOUNT_DEVICE="$ARCHUP_ROOT_PART" | |||
| 11 | + | fi | |||
| 12 | + | ||||
| 13 | + | # Mount @ subvolume as root with optimal btrfs options | |||
| 14 | + | mount -o noatime,compress=zstd,subvol=@ "$MOUNT_DEVICE" /mnt | |||
| 15 | + | ||||
| 16 | + | echo "Mounted @ subvolume to /mnt" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |||
| 17 | + | ||||
| 18 | + | # Create home directory | |||
| 19 | + | mkdir -p /mnt/home | |||
| 20 | + | ||||
| 21 | + | # Mount @home subvolume | |||
| 22 | + | mount -o noatime,compress=zstd,subvol=@home "$MOUNT_DEVICE" /mnt/home | |||
| 23 | + | ||||
| 24 | + | echo "Mounted @home subvolume to /mnt/home" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |||
| 8 | 25 | ||||
| 9 | # Create and mount EFI directory | 26 | # Create and mount EFI directory | ||
| 10 | mkdir -p /mnt/boot | 27 | mkdir -p /mnt/boot | ||
| 11 | mount "$ARCHUP_EFI_PART" /mnt/boot | 28 | mount "$ARCHUP_EFI_PART" /mnt/boot | ||
| 12 | 29 | ||||
| 13 | - | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "✓ Partitions mounted" | |||
| 14 | - | ||||
| 15 | - | echo "Mounted $ARCHUP_ROOT_PART to /mnt" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |||
| 16 | echo "Mounted $ARCHUP_EFI_PART to /mnt/boot" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | 30 | echo "Mounted $ARCHUP_EFI_PART to /mnt/boot" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | ||
| 31 | + | ||||
| 32 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "✓ Partitions mounted" | |||
M install/preflight/begin.sh +14 -0
| @@ -28,4 +28,18 @@ ARCHUP_BOOTLOADER=$(gum choose \ | |||
| 28 | 28 | export ARCHUP_BOOTLOADER | |
| 29 | 29 | echo "Selected bootloader: $ARCHUP_BOOTLOADER" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 30 | 30 | ||
| 31 | + | # Ask for encryption preference (Phase 2) | |
| 32 | + | echo | |
| 33 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Disk Encryption" | |
| 34 | + | gum style --padding "0 0 0 $PADDING_LEFT" "LUKS encryption protects your data with Argon2id (2000ms iteration)" | |
| 35 | + | echo | |
| 36 | + | ||
| 37 | + | if gum confirm "Enable full-disk encryption?" --padding "0 0 1 $PADDING_LEFT"; then | |
| 38 | + | export ARCHUP_ENCRYPTION="enabled" | |
| 39 | + | echo "Encryption: enabled" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 40 | + | else | |
| 41 | + | export ARCHUP_ENCRYPTION="disabled" | |
| 42 | + | echo "Encryption: disabled" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |
| 43 | + | fi | |
| 44 | + | ||
| 31 | 45 | gum style --foreground 2 --padding "1 0 1 $PADDING_LEFT" "✓ Configuration saved" | |
| @@ -28,4 +28,18 @@ ARCHUP_BOOTLOADER=$(gum choose \ | |||||
| 28 | export ARCHUP_BOOTLOADER | 28 | export ARCHUP_BOOTLOADER | ||
| 29 | echo "Selected bootloader: $ARCHUP_BOOTLOADER" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | 29 | echo "Selected bootloader: $ARCHUP_BOOTLOADER" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | ||
| 30 | 30 | ||||
| 31 | + | # Ask for encryption preference (Phase 2) | |||
| 32 | + | echo | |||
| 33 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Disk Encryption" | |||
| 34 | + | gum style --padding "0 0 0 $PADDING_LEFT" "LUKS encryption protects your data with Argon2id (2000ms iteration)" | |||
| 35 | + | echo | |||
| 36 | + | ||||
| 37 | + | if gum confirm "Enable full-disk encryption?" --padding "0 0 1 $PADDING_LEFT"; then | |||
| 38 | + | export ARCHUP_ENCRYPTION="enabled" | |||
| 39 | + | echo "Encryption: enabled" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |||
| 40 | + | else | |||
| 41 | + | export ARCHUP_ENCRYPTION="disabled" | |||
| 42 | + | echo "Encryption: disabled" | tee -a "$ARCHUP_INSTALL_LOG_FILE" | |||
| 43 | + | fi | |||
| 44 | + | ||||
| 31 | gum style --foreground 2 --padding "1 0 1 $PADDING_LEFT" "✓ Configuration saved" | 45 | gum style --foreground 2 --padding "1 0 1 $PADDING_LEFT" "✓ Configuration saved" | ||