summaryrefslogtreecommitdiffstats
path: root/recipes-core/initrdscripts/initramfs-framework-dm
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-core/initrdscripts/initramfs-framework-dm')
-rw-r--r--recipes-core/initrdscripts/initramfs-framework-dm/dmverity63
1 files changed, 63 insertions, 0 deletions
diff --git a/recipes-core/initrdscripts/initramfs-framework-dm/dmverity b/recipes-core/initrdscripts/initramfs-framework-dm/dmverity
new file mode 100644
index 0000000..888052c
--- /dev/null
+++ b/recipes-core/initrdscripts/initramfs-framework-dm/dmverity
@@ -0,0 +1,63 @@
1#!/bin/sh
2
3dmverity_enabled() {
4 return 0
5}
6
7dmverity_run() {
8 DATA_SIZE="__not_set__"
9 ROOT_HASH="__not_set__"
10
11 . /usr/share/misc/dm-verity.env
12
13 C=0
14 delay=${bootparam_rootdelay:-1}
15 timeout=${bootparam_roottimeout:-5}
16 RDEV="$(realpath /dev/disk/by-partuuid/${bootparam_root#PARTUUID=})"
17 while [ ! -b "${RDEV}" ]; do
18 if [ $(( $C * $delay )) -gt $timeout ]; then
19 fatal "Root device resolution failed"
20 exit 1
21 fi
22
23 case "${bootparam_root}" in
24 ID=*)
25 RDEV="$(realpath /dev/disk/by-id/${bootparam_root#ID=})"
26 ;;
27 LABEL=*)
28 RDEV="$(realpath /dev/disk/by-label/${bootparam_root#LABEL=})"
29 ;;
30 PARTLABEL=*)
31 RDEV="$(realpath /dev/disk/by-partlabel/${bootparam_root#PARTLABEL=})"
32 ;;
33 PARTUUID=*)
34 RDEV="$(realpath /dev/disk/by-partuuid/${bootparam_root#PARTUUID=})"
35 ;;
36 PATH=*)
37 RDEV="$(realpath /dev/disk/by-path/${bootparam_root#PATH=})"
38 ;;
39 UUID=*)
40 RDEV="$(realpath /dev/disk/by-uuid/${bootparam_root#UUID=})"
41 ;;
42 *)
43 RDEV="${bootparam_root}"
44 esac
45 debug "Sleeping for $delay second(s) to wait root to settle..."
46 sleep $delay
47 C=$(( $C + 1 ))
48
49 done
50
51 veritysetup \
52 --data-block-size=1024 \
53 --hash-offset=${DATA_SIZE} \
54 create rootfs \
55 ${RDEV} \
56 ${RDEV} \
57 ${ROOT_HASH}
58
59 mount \
60 -o ro \
61 /dev/mapper/rootfs \
62 ${ROOTFS_DIR} || exit 2
63}