-
Notifications
You must be signed in to change notification settings - Fork 0
/
init
37 lines (31 loc) · 1.32 KB
/
init
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
#!/bin/sh
bin/mount -t proc none /proc
bin/mount -t sysfs none /sys
bin/mount -t devtmpfs none /dev
bin/mount -t tmpfs none /run
#Function to parse kernel command line arguments
cmdline() {
local value
value="$(cat /proc/cmdline)"
value="${value##* $1=}"
value="${value%% *}"
[ "$value" != "" ] && echo "$value"
}
# Optimize:
# For usecases where boot time is critical, hardcode the veritysetup parameters in this init file
# instead of reading them from kernel command line arguments using cmdline().
# Caveat being that it would make the initramfs non-generic.
verity_name=$(cmdline verity_name)
bin/veritysetup --verbose --data-block-size=$(cmdline data_block_size) --hash-block-size=$(cmdline hash_block_size) \
create $verity_name $(cmdline data_dev) $(cmdline hash_dev) $(cmdline root_hash)
bin/mount /dev/mapper/$verity_name /mnt/root
bin/mount -t tmpfs tmpfs /mnt/root/etc
bin/mount -t tmpfs tmpfs /mnt/root/var
bin/mount --move /proc /mnt/root/proc
bin/mount --move /sys /mnt/root/sys
bin/mount --move /dev /mnt/root/dev
bin/mount --move /run /mnt/root/run
# Optimize:
# For usecases where boot time is critical, replace the init from systemd-bootchart to systemd.
# Caveat being that it would negate the diagnostic info that systemd-bootchart provides.
exec bin/switch_root /mnt/root /usr/lib/systemd/systemd-bootchart