You are not logged in.

#1 2020-05-28 12:24:30

From: Sweden/Vasterbotten/Rusfors
Registered: 2016-08-11
Posts: 1,182

Chroot help-script

A powerfailure when upgrading or forgotten password, is example when the computer can get unbotable or impossible to log in to.
To remedy it, you can boot an rescue or live CD and chroot in to your faulty installation.

I ad an skript to ease mounting och devices.
Edit it to suite your installation. If you in chroot, need to mount other drives listed in /etc/fstab, just issue command "mount -a"

The script must be run as root.

#  Skript to ease chroot mounts. Adjust devices if applicable
# More about chroot at
echo "  chroot with sda2 mounted at / and sda3 at /boot"
echo "  After finishing work in chroot, make exit and reboot or make umount:"
echo "  'umount -lf /srv/chroot/'"  # lf= --lazy --force
echo ""
echo "  Press ENTER to continye or CTRL+C to abort..."
echo ""
read stdin

mkdir -p /srv/chroot  # -p = --parents (no error if existing, make parent directories as needed)
export MY_CHROOT=/srv/chroot
mount -rw /dev/sda3 $MY_CHROOT # -rw = --read-write
mount -rw /dev/sda2 $MY_CHROOT/boot
mount -o bind -t proc /proc $MY_CHROOT/proc # -o = --options -t = --types
mount -o bind /dev $MY_CHROOT/dev
mount -t devpts /dev/pts $MY_CHROOT/dev/pts
mount -t sysfs /sys $MY_CHROOT/sys
mount -o bind /tmp $MY_CHROOT/tmp
echo "/srv/chroot" > /etc/debian_chroot
chroot $MY_CHROOT /bin/bash
echo ""
echo "  After finishing work in chroot, make exit and reboot or unmount:"
echo "  'umount -lf /srv/chroot/'"  # lf= --lazy --force
echo ""
rm /etc/debian_chroot

Last edited by rbh (2020-05-28 13:34:29)

// Regards rbh

Please read before requesting help: Guide to getting help,
Introduction to the Bunsenlabs Lithium Desktop and other help topics under "Help Resources" on the BunsenLabs menu


#2 2020-05-28 13:30:50

From: Lipsia
Registered: 2015-10-03
Posts: 298

Re: Chroot help-script

Cool, thank you!

Usually I got an USB-key containig rescatux but this comes really handy...

naik --greetz

"Kaum macht [Mensch]* es richtig, funktioniert es sofort!"
BL-Kitchen on GitHub


Board footer

Powered by FluxBB