| Start |
| Manually changing root in a directory
Ensure you met all requirements, as per Requirements
Mount the temporary API filesystems:
If you need to use an internet connection in the chroot environment, copy over the DNS details:
Change root into /location/of/new/root, specifying the shell (`/bin/bash` in this example):
After chrooting it may be necessary to load the local bash configuration:
Optionally, create a unique prompt to be able to differentiate your chroot environment:
When finished with the chroot, you can exit it via:
Unmount the temporary file systems:
|
Requirements - root privileges
- another working Linux environment,such as Live CD boot or an existing distribution
- matching environment architectures of
chroot source and destination (check current environment architecture with uname -m) - kernel modules which you may need in
chroot environment must be loaded (for example, with modprobe) |
| Reasons to use chroot Changing root is commonly done for performing system maintenance on systems where booting and/or logging in is no longer possible. Common examples are: - reinstalling the bootloader
- rebuilding the initramfs image
- upgrading or downgrading packages
- resetting a forgotten password
- building software in a clean root environment
Syntax - chroot [destination path] [shell or command]
|