Created
March 14, 2017 23:07
-
-
Save nmilosev/a50c6d545363dd6058c988894d34df6a to your computer and use it in GitHub Desktop.
This file contains 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
# chroot into a LXC container | |
#!/bin/bash | |
export CONTAINERPATH="/var/lib/lxc/$1" | |
echo "Entering chroot... at $CONTAINERPATH" | |
mount -t proc proc "$CONTAINERPATH/rootfs/proc" | |
mount -t sysfs sys "$CONTAINERPATH/rootfs/sys/" | |
mount -o bind /dev "$CONTAINERPATH/rootfs/dev" | |
mount -o bind /dev "$CONTAINERPATH/rootfs/dev/pts" | |
chroot "$CONTAINERPATH/rootfs" /bin/bash | |
echo "Exiting chroot..." | |
umount "$CONTAINERPATH/rootfs/dev/pts" | |
umount "$CONTAINERPATH/rootfs/dev" | |
umount "$CONTAINERPATH/rootfs/sys/" | |
umount "$CONTAINERPATH/rootfs/proc" | |
echo "Cleaned up..." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment