Chroot

From Notes to self
Revision as of 14:30, 27 December 2023 by Verbovet (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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