Created
March 20, 2020 18:51
-
-
Save cynecx/8899fd60a94acffa1f0e42ac6ea64fdc to your computer and use it in GitHub Desktop.
linux mount/user namespace snippets
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
| 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PandaServices#5413 add me