blob: 888052ccdff6dfd551d502761d17912dc6ecbf59 [file] [log] [blame]
Andrew Geisslercc589282020-09-18 13:34:40 -05001#!/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
Andrew Geisslerd1d22e62020-10-16 10:14:32 -050013 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
Andrew Geisslercc589282020-09-18 13:34:40 -050022
Andrew Geisslerd1d22e62020-10-16 10:14:32 -050023 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
Andrew Geisslercc589282020-09-18 13:34:40 -050050
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}