blob: a47b02c853b948caa09247c17bb96d2b79128db2 [file] [log] [blame]
Andrew Geisslerdc9d6142023-05-19 09:38:37 -05001dm-verity and x86-64 and systemd
2--------------------------------
3In this example, we'll target combining qemux86-64 with dm-verity and
4also systemd - systemd has dm-verity bindings and is more likely to be
5used on x86.
6
7While dm-verity in a qemu environment doesn't make practial sense as a
8deployment - it can be a useful stepping stone for testing and getting to
9a final physical deployment.
10
11Set/uncomment the MACHINE line for "qemux86-64" if you haven't yet. It
12should be the default if unspecified, but check to be sure. As of this
13writing (kernel v6.1) the resulting qemux86-64 build can also be booted
14successfully on physical hardware, but if you don't intend to use qemu,
15you might instead want to choose "genericx86-64"
16
17This will make use of wic/systemd-bootdisk-dmverity.wks.in -- note that it
18contains a dependency on the meta-intel layer for microcode, so you'll need
19to fetch and add that layer in addition to the meta-security related layers.
20
21In addition to the basic dm-verity settings, choose systemd in local.conf:
22
23DISTRO_FEATURES:append = " security systemd"
24VIRTUAL-RUNTIME_init_manager = "systemd"
25EFI_PROVIDER = "systemd-boot"
26PACKAGECONFIG:append:pn-systemd = " cryptsetup"
27
28Note the last line - you won't typically see that in on-line instructions
29for enabling systemd. It is important for dm-verity, since it triggers
30the build and installation of components like this onto the rootfs:
31
32 /lib/systemd/system-generators/systemd-veritysetup-generator
33 /lib/systemd/systemd-veritysetup
34
35Now build the components for the wic image:
36
37 bitbake intel-microcode
38 bitbake core-image-minimal
39
40Assemble the image:
41
42 ------------------------------
43build-qemu-x86_64$wic create systemd-bootdisk-dmverity -e core-image-minimal
44INFO: Building wic-tools...
45
46[...]
47
48INFO: Creating image(s)...
49
50INFO: The new image(s) can be found here:
51 ./systemd-bootdisk-dmverity.wks-202304181413-sda.direct
52
53The following build artifacts were used to create the image(s):
54 BOOTIMG_DIR: /home/paul/poky/build-qemu-x86_64/tmp/work/qemux86_64-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
55 KERNEL_DIR: /home/paul/poky/build-qemu-x86_64/tmp/deploy/images/qemux86-64
56 NATIVE_SYSROOT: /home/paul/poky/build-qemu-x86_64/tmp/work/core2-64-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native
57
58INFO: The image(s) were created using OE kickstart file:
59 /home/paul/poky/meta-security/wic/systemd-bootdisk-dmverity.wks.in
60build-qemu-x86_64$
61 ------------------------------
62
63The "runqemu" script defaults were acceptable for testing with only the
64verity image needing to be specified, i.e.
65
66 runqemu \
67 nographic \
68 qemux86-64 \
69 tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64-*.rootfs.ext4.verity
70
71You will see the above "direct" image file and also similarly named
72individual partition images. To boot on UEFI enabled physical hardware,
73you need to simply write the "direct" image file to a USB stick with dd
74and the partition images can largely be ignored.
75
76Further information on interacting with the systemd UEFI loader is here:
77https://www.freedesktop.org/wiki/Software/systemd/systemd-boot/