Skip to content

Instantly share code, notes, and snippets.

@cynecx
Created March 20, 2020 18:51
Show Gist options
  • Select an option

  • Save cynecx/8899fd60a94acffa1f0e42ac6ea64fdc to your computer and use it in GitHub Desktop.

Select an option

Save cynecx/8899fd60a94acffa1f0e42ac6ea64fdc to your computer and use it in GitHub Desktop.
linux mount/user namespace snippets
mkdir rootfs
cd rootfs
mkdir old_rootfs
mkdir tmp
mkdir usr
mkdir proc
mkdir root
ln -sf usr/lib lib
ln -sf usr/lib lib64
ln -sf usr/lib bin
ln -sf usr/lib sbin
cd ..
unshare --mount --pid --user --map-root-user --fork bash
mount --bind ./rootfs ./rootfs
cd rootfs
mount --bind /usr ./usr
mount -t proc proc ./proc
pivot_root . ./old_rootfs
cd /
umount -l /old_rootfs
rm -r old_rootfs
@PikaBooLord69
Copy link

PandaServices#5413 add me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment