blob: bb07aab5855592c83e6302905c19de3011a3192c [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
13 case "${bootparam_root}" in
14 ID=*)
15 RDEV="$(realpath /dev/disk/by-id/${bootparam_root#ID=})"
16 ;;
17 LABEL=*)
18 RDEV="$(realpath /dev/disk/by-label/${bootparam_root#LABEL=})"
19 ;;
20 PARTLABEL=*)
21 RDEV="$(realpath /dev/disk/by-partlabel/${bootparam_root#PARTLABEL=})"
22 ;;
23 PARTUUID=*)
24 RDEV="$(realpath /dev/disk/by-partuuid/${bootparam_root#PARTUUID=})"
25 ;;
26 PATH=*)
27 RDEV="$(realpath /dev/disk/by-path/${bootparam_root#PATH=})"
28 ;;
29 UUID=*)
30 RDEV="$(realpath /dev/disk/by-uuid/${bootparam_root#UUID=})"
31 ;;
32 *)
33 RDEV="${bootparam_root}"
34 esac
35
36 if ! [ -b "${RDEV}" ]; then
37 echo "Root device resolution failed"
38 exit 1
39 fi
40
41 veritysetup \
42 --data-block-size=1024 \
43 --hash-offset=${DATA_SIZE} \
44 create rootfs \
45 ${RDEV} \
46 ${RDEV} \
47 ${ROOT_HASH}
48
49 mount \
50 -o ro \
51 /dev/mapper/rootfs \
52 ${ROOTFS_DIR} || exit 2
53}