chroot
1. Mount some necessary resources
ARCH_ROOT=/home/fancy/archlinux-root
# mount necessary resources
sudo mount --bind $ARCH_ROOT $ARCH_ROOT
sudo mount -t proc /proc $ARCH_ROOT/proc
sudo mount --rbind /sys $ARCH_ROOT/sys
sudo mount --rbind /dev $ARCH_ROOT/dev
sudo mount --bind -o ro /tmp/.X11-unix $ARCH_ROOT/tmp/.X11-unix
sudo cp /etc/resolv.conf $ARCH_ROOT/etc/resolv.conf
# umount
sudo umount --recursive $ARCH_ROOT
#sudo umount $ARCH_ROOT/dev
#sudo umount $ARCH_ROOT/proc
#sudo umount $ARCH_ROOT/sys
#sudo umount $ARCH_ROOT
#sudo umount $ARCH_ROOT/tmp/.X11-unix
#sudo chmod 1777 /dev/shm
2. X related to enable GUI in chroot
# in host, authorize clients
xauth extract $ARCH_ROOT/root/.Xauthority :0
# chroot to guest
sudo chroot $ARCH_ROOT
# in guest
export XAUTHORITY=/root/.Xauthority
# test in guest, assume arch
pacman -S xorg-eyes #xorg-xauth xorg-server
xeyes
3. Another way to display in current X window
# in host, need bind /tmp/.X11-unix
# disable access control
xhost +
# in guest
xeyes
Another way to display in a nested X window
# in host,need bind /tmp/.X11-unix
sudo apt install xserver-xephyr
Xephyr -screen 1024x768 :1 &
# in guest
DISPLAY=:1
xeyes