Chroot in Ubuntu

30Mar 2010

Chroot in Ubuntu

by Craig Mayhew on Tue 30th Mar 2010 under Linux/Ubuntu
If you ever manage to damage your ubuntu install so badly that it won't boot (as I recently did when trying to remove the gnome GUI) then boot from a LiveCD and then open up a terminal.

Type the following commands:

change to the media directory (where our drives should be)
# cd /media

Create a new directory called Ubuntu (We will use this to mount our boot drive too)
# mkdir ubuntu

Mount the boot drive, you will need to replace X with the correct letter
# mount /dev/sdaX /media/ubuntu

Mount some other required locations
# mount --bind /proc /media/ubuntu/proc
# mount --bind /dev /media/ubuntu/dev
# mount --bind /dev/pts /media/ubuntu/dev/pts

Run chroot, using this command and we are now root as if we had booted from the boot drive and not the liveCD:
# chroot /media/ubuntu

Your now in your Ubuntu system as root. If your unsure precisely why your system won't boot then running an update is usually a good place to start. Good luck!
# aptitude update

Ubuntu   Chroot  


© 2005-2024 Craig Mayhew