Blog

Proper CHROOT in rescue mode using arch-chroot

  |   Linux   |   No comment

Most Sysadmins know how to setup a basic chroot on a mounted filesystem (mount-binding dev, proc and sys) but this does not work in any case; for a complete chroot setup you would aso need dev/pts dev/shm, run, tmp, a working resolve.conf and more. After you have set it up and you want to bring it down, you have to do a lot of typing again. But wait! There is a better solution.

There is a script called arch-chroot shipped with the Archlinux distribution, but it is not limited to be run with Archlinux. It works on any linux distri!

For your convenience, i have created a gist for you. You can also use the Direct download link for wget.

you can install it like this:

wget https://gist.githubusercontent.com/bhelm/65283c37a0cb585089041214002df4f7/raw/536099a5f969a6888c85e48a487ec19870c596a2/arch-chroot.sh
chmod +x arch-chroot.sh
./arch-chroot.sh -h

 

Using this script, i was able to install grub without getting errors like:

grub-install: error: cannot find a device for /boot/grub (is /dev mounted?).
grub-probe: error: cannot find a device for / (is /dev mounted?).

 

If you are looking for a really good rescue system, i recommend the archlinux install image; it contains the arch-chroot script, all lowlevel tools needet to format hard drives and even supports mounting of ntfs read-write and accessing samba shares.

No Comments

Sorry, the comment form is closed at this time.