Skip to content

Instantly share code, notes, and snippets.

@tryp
Created March 8, 2012 14:48
Show Gist options
  • Save tryp/2001338 to your computer and use it in GitHub Desktop.
Save tryp/2001338 to your computer and use it in GitHub Desktop.
chroot into a rootfs for the same architecture
#!/bin/sh
#
# chroot into a rootfs for the same architecture
# usage: sudo ./do_chroot rootdir
echo chrooting into $1
mkdir -p $1/proc
mkdir -p $1/sys
mkdir -p $1/dev
cp /etc/resolv.conf $1/etc
mount --bind /proc $1/proc
mount --bind /sys $1/sys
mount --bind /dev $1/dev
mount --bind /dev/pts $1/dev/pts
chroot $1 /bin/bash
umount $1/dev/pts
umount $1/dev
umount $1/sys
umount $1/proc || umount -lf $1/proc
rm $1/etc/resolv.conf
rm $1/var/lib/dbus/machine-id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment