How to Chroot
prepare the folder :
mount /device/to/chroot /chroot/point
If necessary :
mount /device/of/boot /chroot/point/boot
export PATH="$PATH:/usr/sbin:/sbin:/bin"
cd /location/of/new/root
# mount -t proc proc proc/
# mount --rbind /sys sys/
# mount --rbind /dev dev/
And optionally:
# mount --rbind /run run/
Next, in order to use an internet connection in the chroot environment copy over the DNS details:
# cp /etc/resolv.conf etc/resolv.conf
Finally, to change root into /location/of/new/root using a bash shell:
As a User
#chroot /chroot /bin/su - user
#chroot --userspec=user:user --groups=group1 /chroot /bin/bash
As Root
# chroot /location/of/new/root /bin/bash
export PATH="$PATH:/usr/sbin:/sbin:/bin"
# xhost +local:
# echo $DISPLAY
as the user that owns the X server to see the value of DISPLAY. If the value is ":0" (for example), then in the chroot environment run
# export DISPLAY=:0
2019-04-26 09:57:44
Comments
Add a Comment