Created
September 19, 2022 12:35
-
-
Save sulincix/56b693790bdb4fbd0fca9ce668343e87 to your computer and use it in GitHub Desktop.
Universal deepfreeze linux
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
#!/bin/bash | |
if [[ -e /sbin/init-normal ]] ; then | |
exit | |
fi | |
mv /sbin/init /sbin/init-normal | |
cat > /sbin/init <<EOF | |
#!/bin/bash | |
mount -t tmpfs tmpfs /tmp || true | |
mkdir -p /tmp/work/source /tmp/work/a /tmp/work/b /tmp/work/target || true | |
mount --bind / /tmp/work/source | |
mount -t overlay -o lowerdir=/tmp/work/source,upperdir=/tmp/work/a,workdir=/tmp/work/b overlay /tmp/work/target | |
exec chroot /tmp/work/target /sbin/init-normal | |
EOF | |
chmod 755 /sbin/init |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment