Thursday, October 9, 2014

Linux chroot command

chroot - command
The chroot command creates a shell with an alternate root directory. It hides the content anything outside of this directory. To rescure the system, or for maintenance, you boot off the cd/DVD or ISO image. Your filesystem will be on cdrom's root filesystem not the system disks partition.

You can check with following commands.

# df -h | grep root
# mount | grep root
# ls

Mount your disk based root filesystem.
# mount /dev/mapper/system--ROOT /mnt
# cd /mnt

chroot to the disk mounted mountpoint.
# chroot /mnt
# ls /

review the content before chroot and after chroot. You will not be able to see the content from cd before you chrooted contents.

Note: If you are on rescue mode on redhat based systems using cd/dvd/iso image, your disk based root disk is mounted at /mnt/sysimage. You can simply run # chroot /mnt/sysimage to get into the disk based root fs.

No comments:

Post a Comment