Skip to content

Instantly share code, notes, and snippets.

@hashbrowncipher
Created April 21, 2019 16:42
Show Gist options
  • Save hashbrowncipher/07475d4ad7eb5af2d9aa83d2bad6d938 to your computer and use it in GitHub Desktop.
Save hashbrowncipher/07475d4ad7eb5af2d9aa83d2bad6d938 to your computer and use it in GitHub Desktop.
load a squashfs and run it
#!/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