You are here

How to chroot

Here is a good link on how to Recover a Non-booting Linux System
http://roderick-greening.blogspot.com/2009/09/recover-non-booting-linux-...

and the core:

ubuntu@ubuntu:~$ sudo mount /dev/sda6 /mnt
ubuntu@ubuntu:~$ sudo mount /dev/sda1 /mnt/boot
ubuntu@ubuntu:~$ sudo mount /dev/sda7 /mnt/home

Verify everything looks correct before proceeding (i.e. you got the partitions correct and mounted in the correct places).

Next, you need to take care of /proc and /dev as follows:

ubuntu@ubuntu:~$ sudo mount -t proc none /mnt/proc
ubuntu@ubuntu:~$ sudo mount -o bind /dev /mnt/dev

Ok, now you have setup your chroot environment, and may change into it:

ubuntu@ubuntu:~$ sudo chroot /mnt

from: http://ubuntuforums.org/showpost.php?p=7960338&postcount=3

From Arch...
Here's two scripts I use to chroot:
(replace sda7 with your karmic partition)
Code:
#!/bin/bash
## /mnt
mount /dev/sda7 /mnt/
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
mount --bind /dev/pts /mnt/dev/pts
cp /etc/resolv.conf /mnt/etc/resolv.conf
chroot /mnt/ /bin/bash

Now Inside karmic, I update using this method:

Code:
sudo aptitude update && sudo aptitude full-upgrade

When complete, Ctrl+d to release chroot. Then I run the following script to cleanly unmount everything:

Code:
#!/bin/bash
## /mnt already exists
umount /mnt/dev/pts
umount /mnt/sys
umount /mnt/proc
umount /mnt/dev
umount /mnt
Topic: