I'm running Manjaro alongside Windows on a Dell XPS 13 Plus (9320), using BTRFS for the / and /home mount points and a FAT32 partition for the EFI system. After an update, I lost the GRUB bootloader. In this tutorial, you'll learn how to reinstall GRUB on a BTRFS and UEFI system using a Live USB.
Identify Partitions
To begin, check which partitions belong to your Manjaro installation. Run the following command:
lsblk -f
You'll get an output like this:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 92.9M 1 loop /run/miso/sfs/livefs
loop1 7:1 0 1.2G 1 loop /run/miso/sfs/mhwdfs
loop2 7:2 0 1.8G 1 loop /run/miso/sfs/desktopfs
loop3 7:3 0 939.3M 1 loop /run/miso/sfs/rootfs
sda 8:16 1 14.9G 0 disk /run/miso/bootmnt
sda1 8:17 1 4.2G 0 part
sda2 8:18 1 4M 0 part
nvme0n1 259:0 0 476.9G 0 disk
nvme0n1p1 259:1 0 240M 0 part
nvme0n1p2 259:2 0 128M 0 part
nvme0n1p3 259:3 0 299.2G 0 part
nvme0n1p4 259:4 0 1.2G 0 part
nvme0n1p5 259:5 0 104.3G 0 part
nvme0n1p6 259:6 0 300M 0 part
nvme0n1p7 259:7 0 1.1G 0 part
nvme0n1p8 259:8 0 52G 0 part
nvme0n1p9 259:9 0 17.1G 0 part
nvme0n1p10 259:10 0 1.4G 0 part
In my case, the partition layout is as follows:
- nvme0n1p6 --> EFI system
- nvme0n1p8 -->
/partition - nvme0n1p5 -->
/homepartition
Mount the Top-level BTRFS Volume
As Manjaro is installed on a BTRFS partition, identify which subvolumes are available in the root partition to mount the system correctly.
First, mount the / partition:
sudo mount -o subvolid=5 /dev/nvme0n1p8 /mnt
Replace /dev/nvme0n1p8 with the corresponding / partition of your installation.
Now, list available subvolumes:
sudo btrfs subvolume list /mnt
You'll get an output like this:
ID 256 gen 87366 top level 5 path @
ID 257 gen 87347 top level 5 path @cache
ID 258 gen 87365 top level 5 path @log
If you have the /home directory in the same root partition, you may get the @home subvolume listed.
Mount the Correct Root Subvolume
Once identified, mount the correct root volume:
sudo umount /mnt
sudo mount -o subvol=@ /dev/nvme0n1p8 /mnt
Replace /dev/nvme0n1p8 with the corresponding / partition of your installation.
Create Mount Points
These folders should already exist; we are just ensuring they are present before mounting.
sudo mkdir -p /mnt/var/cache
sudo mkdir -p /mnt/var/log
Mount the Subvolumes
Mount the cache subvolume:
sudo mount -o subvol=@cache /dev/nvme0n1p8 /mnt/var/cache
Replace /dev/nvme0n1p8 with the corresponding / partition of your installation.
Mount the log subvolume:
sudo mount -o subvol=@log /dev/nvme0n1p8 /mnt/var/log
Replace /dev/nvme0n1p8 with the corresponding / partition of your installation.
(Optional) Mount the separate home partition:
sudo mount /dev/nvme0n1p5 /mnt/home
Replace /dev/nvme0n1p5 with the corresponding /home partition of your installation.
Now, verify that all necessary BTRFS subvolumes are mounted and that the mount options are correct (specifically, ensure they are listed as rw for read-write). Run the following command:
mount | grep btrfs
You'll get an output like this:
/dev/nvme0n1p8 on /mnt type btrfs (rw,relatime,ssd,discard=async,space_cache=v2,subvolid=256,subvol=/@)
/dev/nvme0n1p8 on /mnt/var/cache type btrfs (rw,relatime,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/@cache)
/dev/nvme0n1p8 on /mnt/var/log type btrfs (rw,relatime,ssd,discard=async,space_cache=v2,subvolid=258,subvol=/@log)
/dev/nvme0n1p5 on /mnt/home type btrfs (rw,relatime,ssd,discard=async,space_cache=v2,subvolid=5,subvol=/)
Mount the EFI Partition
Finally mount the EFI partition by running the following command:
sudo mount /dev/nvme0n1p6 /mnt/boot/efi
Replace /dev/nvme0n1p6 with the corresponding EFI partition of your installation.
Bind System Directories
Next, bind the system directories. These 'virtual' folders act as a bridge between the Live USB and your Manjaro installation, allowing the repair tools to interact with your hardware:
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo mount --bind /run /mnt/run
Chroot and Reinstall GRUB
Now that all subvolumes and partitions are mounted, and system directories are bound, you can access your Manjaro installation and reinstall GRUB. Run the following commands:
sudo chroot /mnt
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=Manjaro --recheck
grub-mkconfig -o /boot/grub/grub.cfg
GRUB is reinstalled and the bootloader would appear after rebooting.
Top comments (0)