From ArchWiki
Revision as of 22:19, 22 November 2009 by Gen2ly (talk | contribs) (New page to help with other pages that use Changing Root)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

"[Changing Root] on Unix operating systems is an operation that changes the apparent disk root directory for the current running process and its children. A program that is re-rooted to another directory cannot access or name files outside that directory, and the directory is called a "chroot jail"..." [Wikipedia].

Changing root is at times necessary to perform various system operations. Examples would be to reinstall GRUB or to reset a forgotten password. Changing root is often done from from a LiveCD of LiveUSB to enter the installation root partition.

Mounting the device

First, the device or partition with the Linux system on it will need to be mounted. To discover the kernel name of the storage device name, type:

fdisk -l

Create a directory where you would like to mount the partition, then mount the device or partition:

mkdir /mnt/arch
mount /dev/<device-or-partition-name> /mnt/arch

Changing Root

Before you can chroot, you will need to mount the temporary filesystems:

mount -t proc /mnt/arch/proc
mount -t sysfs /mnt/arch/sys
mount -o bind /mnt/arch/dev

Now chroot to your installed device or partition and define your shell:

chroot /mnt/arch /mnt/arch/bin/bash

Exiting chroot

First the chroot shell must be exited:


Then unmount the temporary filesystems and mounted devices then reboot:

umount /mnt/arch/{proc,sys,dev}
umount /mnt/arch