Skip to content

Arch-chroot for EFI/UEFI systems

by </joekamprad> Edited by Bryanpwo 24 March 2021

If your machine doesn’t boot because of issues with GRUB, there is a way to get into your system through the terminal with Change of root or also known as Chroot.

In our case, we have arch-chroot which helps to make the process of mounting some needed stuff into the chroot needed to be able to maintain rescue-related stuff inside the chroot properly.

All you need is the ISO with our live environment to get the job done.

To be able to chroot, you need to know on which partition your boot and your root partition reside. To uncover that information, boot up our ISO, open the terminal, and type:

sudo lsblk -f

Now your terminal displays the partition schemes of the disks it is connected with. This means, it also displays the partition scheme of the USB key (/dev/loop in the example), your machine info usually looks like this:

In this case, the system partitions are on /dev/sda but in your case it can be marked with another letter followed by another number, also the hierarchy can be different in your case. Depending on the way you set partitions upon installation.

For example, it can show /dev/nvme1n1 if you are using nvme drives…

And keep in mind what in your case is your setup! We do only try to show some examples here based on the ways we offer for using an automatic partition on the Calamares Installer.

In general, you need to mount the Root-File-System under /mnt and in case the ESP UEFI fat32 partition inside the RFS under /boot/efi what will be /mnt/boot/efi, in this case, to have it mounted inside the right place on your RFS.

in the most common way you will have two partitions involved only:

  1. ESP (fat32 UEFI) boot partition mostly (default) mounted on /boot/efi (/dev/sda1 in the example above)
  2. / RFS root file system per default it would be ext4 (/dev/sda2 in the example above)

in this case you need to mount RFS under /mnt and ,ESP under /mnt/boot/efi:

sudo mount /dev/sdXn /mnt

Replace /dev/sdXn with the exact partition path for your RFS in the example it would be /dev/sda2

sudo mount /dev/sdXn /mnt/boot/efi

Replace /dev/sdXn with the exact partition path for your RFI system partition in the example it would be /dev/sda1 but could be also something similar to /dev/nvme1n1

There are different ways to create filesystems and partitions during the installation process so you need to know what you have there.

It could be encrypted or using BTRFS subvolumes, encryption added or xfs .. .. using partitions over different drives e.t.c.

To check what filesystem you use take lsblk -f too:

lsblk -f will show used filesystem if you do not remember exactly

For BTRFS subvol schemes:

you need to know your subvol names and their associated mount points inside the system path. You can find the info in systems /etc/fstab and the subvolumes can be listed after mounting the BTRFS filesystem:

sudo mount /dev/sdXn /mnt

sudo btrfs subvolume list -p /mnt

In case you have p.e. subvols for / (root) , /home, /var/cache, and /var/log on UEFI systems you will have the ESP (fat32) partition in addition.

After checking your subvol list you need to unmount the device again to mount it for usage on arch-chroot with the proper subvols:

sudo umount /mnt

Make sure to mount the volumes in the right directories under /mnt…

Not all subvolumes need to get mounted to use arch-chroot it needs mainly the / (@) if you only want to repair grub per example

sudo mount -o subvol=@ /dev/sdXn /mnt

sudo mount -o subvol=@log /dev/sdXn /mnt/var/log

sudo mount -o subvol=@cache /dev/sdXn /mnt/var/cache

sudo mount -o subvol=@home /dev/sdXn /mnt/home

And your ESP needs to get mounted also .. as it is not inside your BTRFS scheme and using its own fat32 partition:

sudo mount /dev/sdXn /mnt/boot/efi

where in all cases /dev/sdXn needs to be changed according to what is used on your install as partition/device path and /boot/efi is what we use per default to mount ESP UEFI partition.

Now you will be able to arch-chroot into your BTRFS system.

Follow at the bottom under Do the arch-chroot: on how to start the chroot.


For encrypted systems:

use lsblk -f to find encrypted devices

In this case /dev/sda2 is the encrypted root partition you need to unlock:

sudo cryptsetup open /dev/sda2 mycryptdevice

It will ask for your luks passphrase and unlocks the device into /dev/mapper/mycryptdevice

This path can be used to mount the device:

sudo mount /dev/mapper/mycryptdevice /mnt

followed by mounting the ESP (EFI-System-Partition) into the already mounted system:

sudo mount /dev/sdXn /mnt/boot/efi

where /dev/sdXn must be the device path to your fat32 EFI partition /dev/sda1 in the example above.

If you want to arch-chroot into encrypted BTRFS install:

The mounting process would change from using the device name itself to /dev/mapper/mycryptdevice

example:

sudo mount -o subvol=@ /dev/mapper/mycryptdevice /mnt

follow up with other subvols if you need them. As described above under For BTRFS subvol schemes

arch-chroot:

With this information, you are able to arch-chroot, so type the following command:

sudo arch-chroot /mnt

Now you’ve chrooted into your installed system, and you are able to access your files, install packages, or alter scripts to rescue your system.

To make sure arch-chroot is working check after your user’s home folder ls /home that should give your username from the installed system.

Connect with us:

Arch-chroot for EFI/UEFI systems

%d bloggers like this: