Created
March 8, 2012 14:48
-
-
Save tryp/2001338 to your computer and use it in GitHub Desktop.
chroot into a rootfs for the same architecture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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