Skip to content

Instantly share code, notes, and snippets.

@cfra
Created September 16, 2015 14:16
Show Gist options
  • Save cfra/25fd85464e2d574499e3 to your computer and use it in GitHub Desktop.
Save cfra/25fd85464e2d574499e3 to your computer and use it in GitHub Desktop.
Wrapper script around chroot
#!/bin/sh
set -e
if [ x"$1" = x"" -o ! -d "/var/chroot/$1" ]; then
echo "Usage: $0 <chroot>" >&2
exit 1
fi
cd /var/chroot/$1
mount -t devtmpfs devtmpfs dev
mount -t proc proc proc
mount -t sysfs sysfs sys
rm -f root/.Xauthority
touch root/.Xauthority
xauth -f root/.Xauthority add $(xauth list | head -n 1)
chroot . /usr/bin/env -i TERM="$TERM" HOME="/root" DISPLAY="$DISPLAY" XAUTHORITY="/root/.Xauthority" debian_chroot="chroot-$1" /bin/bash -l
umount -l dev
umount -l proc
umount -l sys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment