Chroot: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
Suppose that a directory <code>/ | Suppose that a directory <code>/mnt</code> contains a system (file hierarchy). To change root to it (without booting and logging): | ||
* Boot from a rescue CD or USB disk, e.g., Slackware Setup disk | * Boot from a rescue CD or USB disk, e.g., Slackware Setup disk | ||
* <code># for i in /dev /dev/pts /proc /sys; do mount --bind $i / | * <code># for i in /dev /dev/pts /proc /sys; do mount --bind $i /mnt$i; done</code> | ||
* <code># chroot / | * <code># chroot /mnt</code> | ||
To exit from chroot: | To exit from chroot: | ||
* <code># exit</code> | * <code># exit</code> | ||
* <code># for i in /sys /proc /dev/pts /dev; do umount / | * <code># for i in /sys /proc /dev/pts /dev; do umount /mnt$i; done</code> | ||
In <code>/etc/fstab</code> the pseudo filesystems can be mounted as follows: | |||
<pre> | |||
/dev /mnt/dev auto bind 0 0 | |||
/dev/pts /mnt/dev/pts auto bind 0 0 | |||
/sys /mnt/sys auto bind 0 0 | |||
/proc /mnt/proc auto bind 0 0 | |||
</pre> | |||
[[Category: Linux]] | [[Category: Linux]] | ||
Latest revision as of 14:30, 27 December 2023
Suppose that a directory /mnt contains a system (file hierarchy). To change root to it (without booting and logging):
- Boot from a rescue CD or USB disk, e.g., Slackware Setup disk
# for i in /dev /dev/pts /proc /sys; do mount --bind $i /mnt$i; done# chroot /mnt
To exit from chroot:
# exit# for i in /sys /proc /dev/pts /dev; do umount /mnt$i; done
In /etc/fstab the pseudo filesystems can be mounted as follows:
/dev /mnt/dev auto bind 0 0 /dev/pts /mnt/dev/pts auto bind 0 0 /sys /mnt/sys auto bind 0 0 /proc /mnt/proc auto bind 0 0