diff options
author | Alexandru Avadanii <Alexandru.Avadanii@enea.com> | 2021-04-26 14:04:04 +0200 |
---|---|---|
committer | Alexandru Avadanii <Alexandru.Avadanii@enea.com> | 2021-05-27 09:45:38 +0200 |
commit | 580595398d36da3cde87046b3b03b9c2c3831249 (patch) | |
tree | 50789a0a7fed47f812b53f8717650770aed6fa79 | |
parent | 10dfa22f6f20453dc15f801d098b693dac38265e (diff) | |
download | meta-el-nfv-access-580595398d36da3cde87046b3b03b9c2c3831249.tar.gz |
OSTree /boot dir: Remove unused artifacts
OSTree handles the contents of /boot separately from the rest of the
filesystem, see [1].
By default, upstream yocto rootfs generation stores the following
artifacts in /boot:
- kernel-image (bzImage) as /boot/bzImage-...;
- multiple packages that deploy grub.cfg, grubenv and EFI binaries:
* dpkg -S /boot/efi/EFI/BOOT
shim, seloader, ovmf-pkcs7-efi, grub-efi, grub-bootconf, efitools
However, none of these are ever used in Enea Edge, due to the way our
initial installation and subsequent upgrade work:
* live image building copies the kernel image from yocto deploy dir,
EFI binaries from rootfs /boot (this patch changes this to also
copy from the yocto deploy dir "bootloader" dir for uniformity) to
the root of the hddimg image;
* Enea Edge Installer (via utils.sh) creates the ESP partition
and copies all artifacts from hddimg to ESP under /EFI/BOOT [2];
* (currently) subsequent upgrades do _not_ update the contents of the
ESP /EFI/BOOT directory after initial installation;
* subsequent upgrades copy the kernel and ostree-initramfs from OSTree
rootfs (from /usr/lib/modules where ostree-kernel package resides)
to the ESP for SELoader validation;
This flow leaves unused (duplicate) artifacts in the following path:
/ostree/boot.x/poky/<poky hash>/0/boot/
While the kernel-image package can be omitted from installation, since
ostree-kernel package already installs the same binaries in
/usr/lib/modules (where OSTree will look for it), the rest of the
packages (shim, seloader etc.) also install other files to the rootfs
(e.g. CLI tools) and/or are used by the live image (hddimg) build
process as sources when copying said artifacts to the hddimg image; so
we can't simply skip installing them inside the rootfs.
Also, we want non-SOTA artifacts (e.g. rootfs.ext4) to still contain
these artifacts.
So the only sensible solution to avoiding confusion and removing
unused artifacts from OSTree images is to remove them right before
creating the OSTree image.
While at it, add some ENEA-specific comment markers to our prepend/
append fragments to make them stand out.
[1] https://github.com/ostreedev/ostree/blob/v2020.8/docs/\
atomic-upgrades.md#the-ostreeboot-directory
[2] http://sestogerrit02/cgit/linux/meta-enea-virtualization.git/tree/
recipes-enea/nfv-installer/nfv-installer/utils.sh?h=rocko#n230
Change-Id: I470c1c3d19f301cae4b8fbe184aa2906d4a25ddf
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
-rw-r--r-- | classes/override_live-vm-common.inc | 2 | ||||
-rw-r--r-- | images/enea-nfv-access-host-common.inc | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/classes/override_live-vm-common.inc b/classes/override_live-vm-common.inc index 6fabbf0..3ac92b9 100644 --- a/classes/override_live-vm-common.inc +++ b/classes/override_live-vm-common.inc | |||
@@ -15,7 +15,7 @@ efi_populate_common() { | |||
15 | 15 | ||
16 | ## ENEA_start ## | 16 | ## ENEA_start ## |
17 | # Install EFI binaries | 17 | # Install EFI binaries |
18 | install -m 0644 ${IMAGE_ROOTFS}${EFI_FILES_PATH}/*.* ${DEST}${EFIDIR} | 18 | install -m 0644 ${DEPLOY_DIR_IMAGE}/${SBFOLDER}/*.efi ${DEST}${EFIDIR} |
19 | 19 | ||
20 | # Install kernel and initramfs sig | 20 | # Install kernel and initramfs sig |
21 | install -m 0644 ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${SB_FILE_EXT} ${DEST}/${KERNEL_IMAGETYPE}${SB_FILE_EXT} | 21 | install -m 0644 ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${SB_FILE_EXT} ${DEST}/${KERNEL_IMAGETYPE}${SB_FILE_EXT} |
diff --git a/images/enea-nfv-access-host-common.inc b/images/enea-nfv-access-host-common.inc index 8d1a5ff..a8c984f 100644 --- a/images/enea-nfv-access-host-common.inc +++ b/images/enea-nfv-access-host-common.inc | |||
@@ -30,12 +30,15 @@ AUTO_SYSLINUXMENU_x86-64 = "0" | |||
30 | # If building with sota enabled, build the otaimg before the hddimg, because | 30 | # If building with sota enabled, build the otaimg before the hddimg, because |
31 | # the hddimg needs it as a base image | 31 | # the hddimg needs it as a base image |
32 | python __anonymous() { | 32 | python __anonymous() { |
33 | ## ENEA_start ## | ||
33 | if bb.utils.contains('DISTRO_FEATURES', 'sota', True, False, d): | 34 | if bb.utils.contains('DISTRO_FEATURES', 'sota', True, False, d): |
34 | d.appendVarFlag("do_bootimg", "depends", " %s:do_image_ota_ext4" % d.getVar("IMAGE_BASENAME", True)) | 35 | d.appendVarFlag("do_bootimg", "depends", " %s:do_image_ota_ext4" % d.getVar("IMAGE_BASENAME", True)) |
36 | ## ENEA_end ## | ||
35 | } | 37 | } |
36 | 38 | ||
37 | # Append OSTree specific parameters to the kernel command line before creating the live image | 39 | # Append OSTree specific parameters to the kernel command line before creating the live image |
38 | python do_bootimg_prepend () { | 40 | python do_bootimg_prepend () { |
41 | ## ENEA_start ## | ||
39 | if bb.utils.contains('DISTRO_FEATURES', 'sota', True, False, d): | 42 | if bb.utils.contains('DISTRO_FEATURES', 'sota', True, False, d): |
40 | ostree_osname = d.getVar('OSTREE_OSNAME') | 43 | ostree_osname = d.getVar('OSTREE_OSNAME') |
41 | checksum = bb.utils.sha256_file(d.getVar('DEPLOY_DIR_IMAGE') + "/" + d.getVar('OSTREE_KERNEL')) | 44 | checksum = bb.utils.sha256_file(d.getVar('DEPLOY_DIR_IMAGE') + "/" + d.getVar('OSTREE_KERNEL')) |
@@ -44,18 +47,32 @@ python do_bootimg_prepend () { | |||
44 | ostree_params = " ostree=/ostree/boot.1/" + ostree_osname + "/" + checksum + "/0" | 47 | ostree_params = " ostree=/ostree/boot.1/" + ostree_osname + "/" + checksum + "/0" |
45 | 48 | ||
46 | d.setVar("APPEND", d.getVar("APPEND") + ostree_params) | 49 | d.setVar("APPEND", d.getVar("APPEND") + ostree_params) |
50 | ## ENEA_end ## | ||
47 | } | 51 | } |
48 | 52 | ||
49 | # Before building the OSTree image, move DPKG data to /usr/dpkg, because | 53 | # Before building the OSTree image, move DPKG data to /usr/dpkg, because |
50 | # OSTree does not preserve the contents of /var | 54 | # OSTree does not preserve the contents of /var |
51 | IMAGE_CMD_ostree_prepend () { | 55 | IMAGE_CMD_ostree_prepend () { |
56 | ## ENEA_start ## | ||
57 | # Note: We do configure DPKG admindir at build time, but we can't do the same for APT since | ||
58 | # yocto hardcodes /var/lib/dpkg paths in various places in OE-core, which we can't override, | ||
59 | # so instead we move the contents to their expected location here and configure apt at runtime | ||
60 | # via a configuration fragment to use the new location. | ||
52 | mkdir -p usr/dpkg/lib/dpkg | 61 | mkdir -p usr/dpkg/lib/dpkg |
53 | if [ "$(ls -A var/lib/dpkg)" ]; then | 62 | if [ "$(ls -A var/lib/dpkg)" ]; then |
54 | mv var/lib/dpkg/* usr/dpkg/lib/dpkg/ | 63 | mv var/lib/dpkg/* usr/dpkg/lib/dpkg/ |
55 | fi | 64 | fi |
65 | # In Enea Edge, the EFI binaries (shim, seloader etc.) are copied from the yocto deploy dir to | ||
66 | # the installation image (hddimg) - see "classes/override_live-vm-common.inc" in this repo; | ||
67 | # and during Enea Edge installation (via utils.sh) from hddimg to the destination disk. | ||
68 | # Files installed by the package manager end up under OSTree /boot hardlink tree, but are | ||
69 | # never actually used. To avoid confusion and save some resources, clean them up. | ||
70 | rm -rf boot/* | ||
71 | ## ENEA_end ## | ||
56 | } | 72 | } |
57 | 73 | ||
58 | IMAGE_CMD_ota_prepend () { | 74 | IMAGE_CMD_ota_prepend () { |
75 | ## ENEA_start ## | ||
59 | if [ "${OSTREE_BOOTLOADER}" = "grub" ]; then | 76 | if [ "${OSTREE_BOOTLOADER}" = "grub" ]; then |
60 | # Upstream bbclass creates /boot/grub2, complement it with /boot/grub | 77 | # Upstream bbclass creates /boot/grub2, complement it with /boot/grub |
61 | # Note: /boot/grub2 is a dir with /boot/grub2/grub.cfg -> ../loader/grub.cfg symlink | 78 | # Note: /boot/grub2 is a dir with /boot/grub2/grub.cfg -> ../loader/grub.cfg symlink |
@@ -63,4 +80,5 @@ IMAGE_CMD_ota_prepend () { | |||
63 | mkdir -p ${OTA_SYSROOT}/boot | 80 | mkdir -p ${OTA_SYSROOT}/boot |
64 | ln -s loader ${OTA_SYSROOT}/boot/grub | 81 | ln -s loader ${OTA_SYSROOT}/boot/grub |
65 | fi | 82 | fi |
83 | ## ENEA_end ## | ||
66 | } | 84 | } |