Skip to content

Instantly share code, notes, and snippets.

@lincerely
Last active January 11, 2023 23:12
Show Gist options
  • Save lincerely/2a85c633db94ae46329e6c6418066db2 to your computer and use it in GitHub Desktop.
Save lincerely/2a85c633db94ae46329e6c6418066db2 to your computer and use it in GitHub Desktop.
setup a virtual root environment with chroot, unshare and BusyBox
# 1. setup the environment
# apt install busybox-static
mkdir -p test.root/bin
cp /usr/bin/busybox test.root/bin # busybox must be a static binary
# 2. start the virtual env (without root)
unshare --map-root-user chroot test.root /bin/busybox ash
# with root: chroot test.root /bin/busybox ash
# 3. link busybox applets so no need to type busybox everytime
# inside the busybox shell:
# $ cd bin
# $ /bin/busybox --install -s .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment