aboutsummaryrefslogtreecommitdiff
path: root/initramfs_init
blob: b1aface1b4436153a774bc3956626659bf0eac48 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh

echo "[yerba-initramfs/init] DEBUG: running ls on /"
ls /

mkdir -p /proc /sys /dev

mount -t proc none /proc
mount -t sysfs none /sys
mount -t devtmpfs none /dev

echo "[yerba-initramfs/init] Mounted /dev, /proc, /sys respectively"

# wait for CD-ROM??
sleep 1

mkdir -p /mnt/iso
ls /mnt/iso

mount /dev/sr0 /mnt/iso
echo "[yerba-initramfs/init] Mounted /dev/sr0 (ISO root)"
echo "[yerba-initramfs/init] DEBUG: running ls on /mnt/iso"

mkdir -p /mnt/root
mount -t squashfs -o loop /mnt/iso/yerba/rootfs.squashfs /mnt/root
echo "[yerba-initramfs/init] Mounted squashfs at /mnt/root"
echo "[yerba-initramfs/init] DEBUG: running ls on /mnt/root"
ls /mnt/root

mkdir -p /mnt/overlay
mount -t tmpfs tmpfs /mnt/overlay
mkdir -p /mnt/overlay/upper /mnt/overlay/work /mnt/overlay/merged
echo "[yerba-initramfs/init] Mounted tmpfs at /mnt/overlay and created upper, work & merged directories"

mount -t overlay overlay -o lowerdir=/mnt/root,upperdir=/mnt/overlay/upper,workdir=/mnt/overlay/work /mnt/overlay/merged
echo "[yerba-initramfs/init] Mounted OverlayFS at /mnt/overlay/merged"

if [ ! -c /dev/console ]; then
	echo "[yerba-initramfs/init] console device not found, creating"
	mknod -m 600 /dev/console c 5 1
fi


if [ ! -c /dev/tty0 ]; then
	echo "[yerba-initramfs/init] tty0 device not found, creating"
	mknod -m 620 /dev/tty0 c 4 0
fi

echo "[yerba-initramfs/init] Switching to overlay root..."
exec switch_root /mnt/overlay/merged /init

echo "[yerba-initramfs/init] switch_root failed, dropping to shell"
exec /bin/sh