-
-
Save hashbrowncipher/07475d4ad7eb5af2d9aa83d2bad6d938 to your computer and use it in GitHub Desktop.
load a squashfs and run it
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
#!/bin/bash | |
set -x | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
function poweroff_before_panic { | |
poweroff -f | |
} | |
trap poweroff_before_panic EXIT | |
mount -o remount,rw / | |
ifup -a | |
curl -sS -o root/ubuntu.squashfs 10.0.2.2:8080/ubuntu.squashfs | |
mkdir /run/roots | |
mount -t tmpfs -o suid,exec none /run/roots | |
cd /run/roots | |
mkdir state work image old | |
mount -t squashfs /root/ubuntu.squashfs image | |
mount -t overlay \ | |
-o lowerdir=image,upperdir=state,workdir=work \ | |
overlay /mnt | |
cd /mnt | |
mount --move /sys sys | |
mount --move /dev dev | |
mount --move /run run | |
mount --move /proc proc | |
pivot_root . run/roots/old | |
exec /sbin/init |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment