summaryrefslogtreecommitdiff
path: root/experiments/04_20251216_pkg_store/init
blob: 742270ecec8b077a99faba816c8ad4a8ad825ece (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh

echo "creating /new_root_base..."
busybox mkdir /new_root_base
busybox mount -t tmpfs tmpfs /new_root_base
busybox cp -r bin etc lib lib64 sbin usr var /new_root_base
busybox ln -s usr/games/sl /new_root_base/init

busybox mkdir /new_root_base/dev
busybox mkdir /new_root_base/proc
busybox mkdir /new_root_base/sys

echo "mounting /pkg_store..."
busybox mkdir /pkg_store
busybox mount -t 9p host0 -o trans=virtio,version=9p2000.L /pkg_store

echo "merging store into /new_root..."
export PKG_DIRS=$(
	busybox find /pkg_store -mindepth 1 -maxdepth 1 -type d |\
	busybox paste -sd ":" -
)
busybox mkdir /new_root
busybox mount -t overlay overlay -olowerdir="/new_root_base:$PKG_DIRS" /new_root

echo "mounting special filesystems..."
busybox mount -t devtmpfs 	udev  	/new_root/dev
busybox mount -t proc     	proc  	/new_root/proc
busybox mount -t sysfs    	sysfs 	/new_root/sys

echo "switching to /new_root..."
exec busybox switch_root /new_root /init
#exec busybox sh