-
-
Save betaboon/bd59d97984ba494f898c8780dcd62388 to your computer and use it in GitHub Desktop.
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
#! @shell@ | |
echo | |
echo -e "\e[1;32m<<< NixOS root-overlay >>>\e[0m" | |
echo | |
stage1Init="@bootStage1@" | |
echo "stage-1-script: $stage1Init" | |
setPath() { | |
local dirs="$1" | |
export PATH=/empty | |
for i in $dirs; do | |
PATH=$PATH:$i/bin | |
if test -e $i/sbin; then | |
PATH=$PATH:$i/sbin | |
fi | |
done | |
} | |
fail() { | |
echo "entering shell..." | |
setsid @shell@ -c "exec @shell@" | |
} | |
setPath "@path@" | |
modprobe overlay | |
targetRoot=/overlay | |
mount -n -t tmpfs overlay-tmp /overlayfs | |
mkdir /overlayfs/oldroot | |
mkdir /overlayfs/rw | |
mount -t tmpfs overlay-rw-tmp /overlayfs/rw | |
mkdir /overlayfs/rw/upper | |
mkdir /overlayfs/rw/work | |
mount --bind / /overlayfs/oldroot | |
mount -n -t overlay -o lowerdir=/overlayfs/oldroot,upperdir=/overlayfs/rw/upper,workdir=/overlayfs/rw/work overlay-root $targetRoot | |
cd $targetRoot | |
mkdir oldroot | |
pivot_root . oldroot | |
exec chroot . "$stage1Init" | |
fail |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment