Skip to content

Instantly share code, notes, and snippets.

@Mat1az
Created April 20, 2024 15:57
Arch BTRFS Boot Repair

BTRFS Boot Repair Walkthrough

Use Case

  • /dev/sdX1 (BOOT) <- Altered, Deleted, Corrupt
  • /dev/sdX2 (@, @home, @pkgs...)

Tools to Use

  • SystemRescue 10.00 (USB Bootable)

Step-to-Step

  1. Boot into SystemRescue
  2. Carefully identify the Disk

    lsblk

  3. Use fdisk into your entire disk

    fdisk /dev/sdX

    1. Enter 'd'. Select and delete the BOOT partition
    2. Enter 'n'. To create a new partition with 512M. (Enter -> "+512M" -> Enter)
    3. Enter 't', then option '1'. To label the partition as EFI BOOT.
    4. Enter 'w'. To confirm the changes. Verify after with 'p'
    • Format the partition created.

      mkfs.vfat -F 32 /dev/sdX1

  4. Mount & chroot your system

    mount /dev/sdX2 /mnt -o subvol=@

    mount /dev/sdX1 /mnt/boot

    mount --bind /sys /mnt/sys

    mount --bind /dev /mnt/dev

    mount --bind /proc /mnt/proc

    chroot /mnt

  5. Once in chroot, you can install systemd-boot
    1. Install systemd-boot:

      bootctl install

    2. Install the images

      sudo pacman -S linux linux-headers

    3. Create & configure the entries

      nano /boot/loader/entries/arch.cfg

      title Arch Linux
      linux /vmlinuz-linux
      initrd /initramfs-linux.img
      options root=PARTUUID=HERE-YOUR-ROOT-PARTUUID rootflags=subvol=@ rw
      

      blkid /dev/sdX2 -s PARTUUID >> /boot/loader/entries/arch.cfg

    4. Modify /etc/fstab
      • Boot partition has been deleted, so UUID is not the same, just update it.

      blkid /dev/sdX1 -s UUID

      nano /etc/fstab

      UUID=YOUR-NEW-UUID          /boot           vfat ...
      
    5. At this point you have successfully recovered the Linux Boot Manager and your Arch OS. However, you still need to create the windows.cfg entry later in case of Dual-Boot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment