HOWTO: chroot from a LiveCD
Boot a Sabayon Linux LiveCD/DVD or other Live disc. Get to a virtual terminal (console) or open a Konsole/Terminal window on the Desktop, and log-in as the root user.
Mount the root partition of the installed system (and, if you have /boot on a separate partition, mount that too). If separate partitions are used for other areas of the system (for example, a separate partition for /var/log) then you will need to mount them too. Additionally, mount the /dev and /proc filesystems so that they can be used by the chrooted environment.
In the following example, /dev/hda1 is the /boot partition and /dev/hda3 is the root partition. Obviously replace those with the device names for your boot partition (if you have one) and your root partition. If your partition names are of the form /dev/sd<letter><number> rather than /dev/hd<letter><number> then obviously use that form instead. Obviously, if you do not have /boot on a separate partition to / (root) then you should omit the mount and umount commands referring to /boot.
# mkdir -p /mnt/sabayon/boot # mount /dev/hda3 /mnt/sabayon # mount /dev/hda1 /mnt/sabayon/boot # mount -t proc none /mnt/sabayon/proc # mount -o bind /dev /mnt/sabayon/dev
So now we are set to enter into our installed system:
# chroot /mnt/sabayon /bin/bash # env-update # source /etc/profile # export PS1="(chroot) $PS1"
You should then end up with the following prompt:
Grub2 reads the /etc/mtab file to ascertain the filesystems that are currently mounted, so /etc/mtab must be up-to-date. If you do not have a separate boot partition then update /etc/mtab using the following command:
(chroot) # grep -v rootfs /proc/mounts > /etc/mtab
or the following command if you do have a separate boot partition:
(chroot) # cp /proc/mounts /etc/mtab
From now on, you can enter commands as if you were using your installed system directly. You could, for example, install a package by using either the equo or emerge commands. The ability to act directly on the installed system like this is very useful in the event that something is broken and you cannot boot to a working system. You might want to revert to an earlier version of a video driver that you know works, or you might want to fix the kernel config and rebuild it because a change you made to the kernel earlier resulted in a kernel panic when you rebooted. And so on.
(chroot) # <enter any command you want>
Once you have finished, you can exit from the chroot environment and unmount the drives:
(chroot) # exit # umount /mnt/sabayon/boot /mnt/sabayon/dev /mnt/sabayon/proc /mnt/sabayon
Reboot the PC. If your actions during the chroot session were successful then your installed system should boot normally.