Skip to content

Instantly share code, notes, and snippets.

@XTechnology-TR
Forked from f4str/btrfs-chroot-guide.md
Created December 2, 2025 23:27
Show Gist options
  • Select an option

  • Save XTechnology-TR/fa26e9f8d0a9f46a4ba1f0b88f6d799e to your computer and use it in GitHub Desktop.

Select an option

Save XTechnology-TR/fa26e9f8d0a9f46a4ba1f0b88f6d799e to your computer and use it in GitHub Desktop.
Btrfs Chroot Guide

Btrfs Chroot Guide

Guide to chroot into Debian or Fedora systems to change the password and/or reinstall GRUB.

Mount Filesystems

Mount the btrfs subvolumes. Subvolumes @ and @home are required. Typically @cache, @log, and @swap are not needed.

sudo mount /dev/nvme0n1p2 /mnt -t btrfs -o subvol=@
sudo mount /dev/nvme0n1p2 /mnt/home -t btrfs -o subvol=@home

Mount the EFI partition. This assumes ESP is on /boot/efi.

sudo mount /dev/nvme0n0p1 /mnt/boot/efi

Mount the virtual filesystems.

sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo mount --bind /run /mnt/run

Load the efivars.

sudo modprobe efivarfs

# if above fails
sudo mount -t efivarfs none /sys/firmware/efi/efivars

Mount the efivars.

sudo mount --bind /sys/firmware/efi/efivars /mnt/sys/firmware/efi/efivars

You can now chroot into the system.

sudo chroot /mnt

Change Password

After chrooting in, you can change the password of any user.

passwd USER

Reinstall GRUB

On Debian systems, use the following method. Install to the drive, not the partition.

# reinstall grub package
apt install --reinstall grub-efi

# recreate grub config
grub-install /dev/nvme0n1
update-grub

On Fedora systems, use the following method.

# remove shim
rm /boot/efi/EFI/fedora/grub.cfg

# reinstall grub package
dnf reinstall grub2-efi grub2-efi-modules grub2-common shim

# recreate grub config
grub2-mkconfig -o /boot/grub2/grub.cfg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment