Chroot into linux partition

Every linux administrator should learn how to chroot into another linux system that needs maintenance or rescue. We take as an example that your computer crashed after an update and now it is booting into busy box. After you type dmesg command you realise that your computer was not able too mount root partition and it needs reparation.

What you need to rescue your harddrive is USB stick or CD with Ubuntu OS. Boot your computer and from the boot menu choose to run live version of the OS.

Now find out root partition of the system. Issue at command line:

fdisk -l

The root partition is marked with a (*) star. Mine root partition is located at /dev/sda2 so I will mount it like this:

mount /dev/sda2 /mnt

Now we need to mount virtual filesystems. These are /dev and /proc. It’s quite simple to mount it:

mount -t proc none /mnt/proc
mount -o bind /dev /mnt/dev

Now we are ready to enter the environment with the chroot command like this:

chroot /mnt

You are now ready to work in your present filesystem like to update your system, install or remove packages or whatsoever.

Leave a Comment