Debian Codegraph @

dracut/modules.d/50kiwi-verity/README.rst

raw
1 kiwi-parse-verity
2 =================
3
4 Overview
5 --------
6
7 This tool is used to parse the information stored by
8 `Kiwi <https://osinside.github.io/kiwi/>`__ inside the unused space of a
9 disk partition when using a SquashFS root filesystem backed by
10 ``dm-verity``. This data is stored at a known offset (generally 4096
11 bytes, or 1 block, from the end of the partition) and follows the layout
12 as described in the `Kiwi
13 documentation <https://osinside.github.io/kiwi/image_description/elements.html#preferences-type>`__
14 for the attribute ``embed_verity_metadata``.
15
16 Usage
17 -----
18
19 The following parameters are required in the Kiwi appliance description:
20
21 - ``verity_blocks="all"``
22 - ``embed_verity_metadata="true"``
23
24 The tool is used to pull a specific entry from the metadata and will
25 return that entry as plain text. It can be called using the following
26 syntax:
27
28 ::
29
30 kiwi-parse-verity -p <path to partition/device> -o <data type>
31
32 The data type is one of the entries stored by Kiwi inside the metadata,
33 such as ``root-hash`` or ``algorithm``. More information about the
34 parameters can be found by calling ``kiwi-parse-verity --help``.
35
36 You will probably need all of the metadata to successfully map the
37 device, as Kiwi sets up the ``dm-verity`` device with the
38 ``--no-superblock`` option, which does not store any data inside the
39 partition, meaning all parameters need to be passed to it on the command
40 line.
41
42 Example
43 ~~~~~~~
44
45 Detailed example of pulling all of the metadata from the partition and
46 mapping the device using ``veritysetup``:
47
48 ::
49
50 VERITY_ROOT=/dev/sda7
51
52 ROOT_HASH=$(kiwi-parse-verity -p ${VERITY_ROOT} -o root-hash)
53 ALGORITHM=$(kiwi-parse-verity -p ${VERITY_ROOT} -o algorithm)
54 HASH_TYPE=$(kiwi-parse-verity -p ${VERITY_ROOT} -o hash-type)
55 HASH_BLOCK_SIZE=$(kiwi-parse-verity -p ${VERITY_ROOT} -o hash-blocksize)
56 DATA_BLOCK_SIZE=$(kiwi-parse-verity -p ${VERITY_ROOT} -o data-blocksize)
57 SALT=$(kiwi-parse-verity -p ${VERITY_ROOT} -o salt)
58 DATA_BLOCKS=$(kiwi-parse-verity -p ${VERITY_ROOT} -o data-blocks)
59 HASH_START_BLOCK=$(kiwi-parse-verity -p ${VERITY_ROOT} -o hash-start-block)
60 HASH_OFFSET=$(( ${HASH_START_BLOCK} * ${HASH_BLOCK_SIZE} ))
61
62 veritysetup open ${VERITY_ROOT} verityRoot ${VERITY_ROOT} ${ROOT_HASH} \
63 --no-superblock --hash ${ALGORITHM} --format ${HASH_TYPE} \
64 --hash-block-size ${HASH_BLOCK_SIZE} --data-block-size ${DATA_BLOCK_SIZE} \
65 --salt ${SALT} --data-blocks ${DATA_BLOCKS} --hash-offset ${HASH_OFFSET}
66
67 The device will then be mapped to ``/dev/mapper/verityRoot``.