diff options
| author | Craig Jennings <c@cjennings.net> | 2026-01-25 00:10:21 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-01-25 00:10:21 -0600 |
| commit | 124ccfabcf6a029d2c98fb22903b7f9576f459ee (patch) | |
| tree | 504fdd04b17b99285b3dabb883f3aa3d7592af12 /custom/lib/btrfs.sh | |
| parent | 5d35df670a6780a12634e6f0ccbb918f53f355eb (diff) | |
| download | archangel-124ccfabcf6a029d2c98fb22903b7f9576f459ee.tar.gz archangel-124ccfabcf6a029d2c98fb22903b7f9576f459ee.zip | |
Fix GRUB boot for btrfs with subvolumes
- Store GRUB modules on EFI partition (FAT32) to avoid btrfs
subvolume path prefix issues (/@/boot/grub not found)
- Create symlink /boot/grub -> /efi/grub for grub-btrfs compatibility
- Add sync after grub-mkconfig to ensure FAT32 write completion
- Add sync before unmounting to prevent data loss on VM shutdown
- Update snapper-firstboot to use /efi/grub/grub.cfg path
- Update multi-disk GRUB functions for consistency
Diffstat (limited to 'custom/lib/btrfs.sh')
| -rw-r--r-- | custom/lib/btrfs.sh | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/custom/lib/btrfs.sh b/custom/lib/btrfs.sh index afd9e4e..5c25526 100644 --- a/custom/lib/btrfs.sh +++ b/custom/lib/btrfs.sh @@ -456,8 +456,8 @@ configure_snapper() { echo '# Create genesis snapshot' echo 'snapper -c root create -d "genesis"' echo '' - echo '# Update GRUB' - echo 'grub-mkconfig -o /boot/grub/grub.cfg' + echo '# Update GRUB (config on EFI partition)' + echo 'grub-mkconfig -o /efi/grub/grub.cfg' echo '' echo 'echo "Snapper configuration complete!"' } > /mnt/usr/local/bin/snapper-firstboot @@ -545,21 +545,28 @@ EOF fi fi - # Create /boot/grub directory - mkdir -p /mnt/boot/grub + # Create grub directory on EFI partition + # GRUB modules on FAT32 EFI partition avoid btrfs subvolume path issues + mkdir -p /mnt/efi/grub - # Install GRUB to EFI with btrfs support - # Use --boot-directory to ensure modules are found correctly + # Install GRUB with boot-directory on EFI partition info "Installing GRUB to EFI partition..." arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/efi \ - --bootloader-id=GRUB --boot-directory=/boot \ + --bootloader-id=GRUB --boot-directory=/efi \ || error "GRUB installation failed" - # Generate GRUB config + # Create symlink BEFORE grub-mkconfig (grub-btrfs expects /boot/grub) + rm -rf /mnt/boot/grub 2>/dev/null || true + arch-chroot /mnt ln -sfn /efi/grub /boot/grub + + # Generate GRUB config (uses /boot/grub symlink -> /efi/grub) info "Generating GRUB configuration..." arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg \ || error "Failed to generate GRUB config" + # Sync to ensure grub.cfg is written to FAT32 EFI partition + sync + # Enable grub-btrfsd for automatic snapshot menu updates info "Enabling grub-btrfs daemon..." arch-chroot /mnt systemctl enable grub-btrfsd @@ -603,7 +610,7 @@ install_grub_all_efi() { arch-chroot /mnt grub-install --target=x86_64-efi \ --efi-directory="$chroot_efi_dir" \ --bootloader-id="$bootloader_id" \ - --boot-directory=/boot \ + --boot-directory=/efi \ || warn "GRUB install to $efi_part may have failed (continuing)" ((++i)) @@ -645,14 +652,14 @@ sync_grub() { if [[ $i -eq 0 ]]; then # Primary - just reinstall GRUB grub-install --target=x86_64-efi --efi-directory="$PRIMARY_EFI" \ - --bootloader-id=GRUB --boot-directory=/boot 2>/dev/null || true + --bootloader-id=GRUB --boot-directory=/efi 2>/dev/null || true else # Secondary - mount, install, unmount local mount_point="/tmp/efi-sync-$i" mkdir -p "$mount_point" mount "$part" "$mount_point" 2>/dev/null || continue grub-install --target=x86_64-efi --efi-directory="$mount_point" \ - --bootloader-id="GRUB-disk$((i+1))" --boot-directory=/boot 2>/dev/null || true + --bootloader-id="GRUB-disk$((i+1))" --boot-directory=/efi 2>/dev/null || true umount "$mount_point" 2>/dev/null || true rmdir "$mount_point" 2>/dev/null || true fi @@ -787,6 +794,9 @@ btrfs_cleanup() { # Unmount in reverse order info "Unmounting subvolumes..." + # Sync all filesystems before unmounting (important for FAT32 EFI partition) + sync + # Unmount EFI first umount /mnt/efi 2>/dev/null || true |
