Arch Linux - How to Chroot
There are different scenarios where you might want to know how to chroot on Arch Linux. You might do this when recovering a system after booting from a rescue disk. You might also be building one system from another system. We are going to show you how this is done. We are assuming that you are running as root for this.
To chroot on arch you just need to run this command:
arch-chroot /mnt
Of course this will usually only be useful if you have a system mounted over this directory. In practice, you will probably need to do a bit more to get yourself setup.
You might start out by checking what block devices are present on the system.
lsblk
You will generally need to mount the root partition but you may or may not need to mount other partitions depending on whether or not they are separate from your root partition.
You might mount your root file system like this:
mount /dev/sda1 /mnt
Then you might mount boot, home, and var like this:
mount /dev/sda2 /mnt/boot
mount /dev/sda3 /mnt/home
mount /dev/sda4 /mnt/var
Next you will want to actually go into the directory to do a few things before chrooting.
cd /mnt
Mount a few virtual filesystems that you will probably need:
mount --rbind /dev dev/
mount --rbind /sys sys/
mount -t proc /proc proc/
Finally, you will want to actually chroot:
arch-chroot /mnt
More - Arch Linux How to Chroot and Why
There are several reasons that you might want to use chroot.
- You may have forgotten your password and need to reset it.
- You may want to build packages in a clean environment.
- You may need to upgrade or downgrade packages.
- You could be reinstalling the bootloader on your system.
- You may find yourself rebuilding the initramfs image.
References
- Enter chroot environment in Arch Linux
- Install Arch Linux from existing Linux
- Arch Linux Install
- Arch Wiki - Chroot