Announcement

Collapse
No announcement yet.

How to repair/re-install GRUB2 from LiveUSB when using BTRFS subvolumes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to repair/re-install GRUB2 from LiveUSB when using BTRFS subvolumes

    I had a fresh KDEneon install to a VM that failed to install GRUB initially for some unknown reason. So I booted back to the LiveUSB and mounted the virtual drive and sure enough - no grub files present in /boot/grub. So I tried to reinstall GRUB from the LiveUSB session and had a heck of a time until I realized the errors I was getting in step 4 - file not found, operation not permitted, etc. - were due to root being in a subvolume. I had mounted the whole file system instead.

    I decided to write this up in case anyone else runs into this. This How-To was tested on KDEneon in a virtual machine.

    For this How To:
    • The boot drive is /dev/sda
    • EFI (if applicable) is on “/dev/sda1”
    • The BTRFS root file system is on “/dev/sda2”
    • The root subvolume is “@”
    Adjust the device names and/or subvolume name in the instructions accordingly for your installation.

    Steps:

    1. Boot to a LiveUSB
    2. Mount the root file system
    Code:
    sudo mount -o subvol=@ /dev/sda2 /mnt
    Note the use of the mount option “-o subvol=@”. This is the critical difference between a BTRFS installation vs. other file systems. The default for *buntu installations is to use "@" as the root subvolume.

    3. Mount the folders for the chroot:
    Code:
    for i in dev dev/pts sys proc run; do sudo mount --bind /$i /mnt/$i; done
    If you are using UEFI, you should mount the EFI boot partition as well:
    Code:
    sudo mount /dev/sda1 mnt/boot/efi
    4. “chroot” root and reinstall GRUB
    Code:
    sudo chroot /mnt
    5. Reinstall and update the GRUB bootloader:
    Code:
    sudo grub-install /dev/sda
    sudo update-grub
    6. Leave chroot and shutdown:
    Code:
    exit
    poweroff
    You may now remove the LiveUSB and power up again. Your install should now boot correctly.




    Please Read Me
Working...
X