Add support for EROFS
cover Add support for EROFS
EROFS is a read-only file system that can act as alternative to squashfs that we so far use for our A/B OTA update setups. It can perform faster during runtime but may come with larger storage demand. See [1] for some comparison.
We just enabled support for it in our 6.1 defconfigs, and this series now enable CIP core to switch from squashfs to EROFS when requested.
Jan
[1] https://sigma-star.at/blog/2022/07/squashfs-erofs
Jan Kiszka (6):
Make the read-only rootfs type configurable
initramfs-crypt-hook: Prepare for EROFS as alternative Add initramfs-erofs-hook
Introduce class for generating EROFS images
linux-cip: Update cip-kernel-config revision
kas: Add option for selecting read-only rootfs type
Kconfig | 16 +++++++++
classes/erofs.bbclass | 34 +++++++++++++++++++
classes/swupdate.bbclass | 3 +-
classes/verity.bbclass | 2 +-
conf/distro/cip-core-common.inc | 4 ++-
conf/layer.conf | 2 +-
kas/opt/erofs.yml | 16 +++++++++
kas/opt/swupdate.yml | 8 ++---
.../files/encrypt_partition.script | 2 +-
...ook_0.2.bb => initramfs-crypt-hook_0.3.bb} | 0
.../initramfs-erofs-hook/files/erofs.hook | 25 ++++++++++++++
.../initramfs-erofs-hook_0.1.bb | 24 +++++++++++++
recipes-kernel/linux/cip-kernel-config.inc | 2 +-
wic/bbb-efibootguard.wks.in | 2 +-
wic/hihope-rzg2m-efibootguard.wks.in | 2 +-
wic/qemu-arm64-efibootguard.wks.in | 2 +-
wic/qemu-riscv64-efibootguard.wks.in | 2 +-
wic/x86-uefi-efibootguard.wks.in | 2 +-
18 files changed, 133 insertions(+), 15 deletions(-)
create mode 100644 classes/erofs.bbclass
create mode 100644 kas/opt/erofs.yml
rename recipes-initramfs/initramfs-crypt-hook/{initramfs-crypt-hook_0.2.bb => initramfs-crypt-hook_0.3.bb} (100%)
create mode 100644 recipes-initramfs/initramfs-erofs-hook/files/erofs.hook
create mode 100644 recipes-initramfs/initramfs-erofs-hook/initramfs-erofs-hook_0.1.bbSignature · 1 line
2.43.0
PATCH 1/6 Make the read-only rootfs type configurable
From: Jan Kiszka <[email protected]>
We so far use squashfs here and will keep that as default. But there will be an option in the future to select EROFS as alternative. Prepare for that.
--- classes/swupdate.bbclass | 3 ++- classes/verity.bbclass | 2 +- conf/distro/cip-core-common.inc | 4 +++- kas/opt/swupdate.yml | 8 ++++---- wic/bbb-efibootguard.wks.in | 2 +- wic/hihope-rzg2m-efibootguard.wks.in | 2 +- wic/qemu-arm64-efibootguard.wks.in | 2 +- wic/qemu-riscv64-efibootguard.wks.in | 2 +- wic/x86-uefi-efibootguard.wks.in | 2 +- 9 files changed, 15 insertions(+), 12 deletions(-)
classes/swupdate.bbclass +2 -1
@@ -12,7 +12,7 @@ inherit template -SWU_ROOTFS_TYPE ?= "squashfs" +SWU_ROOTFS_TYPE ?= "${RO_ROOTFS_TYPE}" SWU_ROOTFS_NAME ?= "${IMAGE_FULLNAME}" # compression type as defined by swupdate (zlib or zstd). Set to empty string to disable compression SWU_COMPRESSION_TYPE ?= "zlib"
@@ -55,6 +55,7 @@ IMAGE_SRC_URI:swu += "file://${SWU_DESCRIPITION_FILE_BOOTLOADER}.tmpl" IMAGE_TEMPLATE_FILES:swu = "${SWU_DESCRIPTION_FILE}.tmpl" IMAGE_TEMPLATE_FILES:swu += "${SWU_DESCRIPITION_FILE_BOOTLOADER}.tmpl" IMAGE_TEMPLATE_VARS:swu = " \ + RO_ROOTFS_TYPE \ SWU_ROOTFS_ARTIFACT_NAME \ TARGET_IMAGE_UUID \ ABROOTFS_PART_UUID_A \
classes/verity.bbclass +1 -1
@@ -12,7 +12,7 @@ IMAGE_TYPEDEP:verity = "${VERITY_IMAGE_TYPE}" IMAGER_INSTALL:verity += "cryptsetup" -VERITY_IMAGE_TYPE ?= "squashfs" +VERITY_IMAGE_TYPE ?= "${RO_ROOTFS_TYPE}" VERITY_INPUT_IMAGE ?= "${IMAGE_FULLNAME}.${VERITY_IMAGE_TYPE}" VERITY_OUTPUT_IMAGE ?= "${IMAGE_FULLNAME}.verity" VERITY_IMAGE_METADATA = "${VERITY_OUTPUT_IMAGE}.metadata"
conf/distro/cip-core-common.inc +3 -1
@@ -1,7 +1,7 @@ # # CIP Core, generic profile # -# Copyright (c) Siemens AG, 2019-2023 +# Copyright (c) Siemens AG, 2019-2024 # # Authors: # Jan Kiszka <[email protected]>
@@ -15,6 +15,8 @@ WKS_FILE ?= "${MACHINE}.wks" CIP_IMAGE_OPTIONS ?= "" +RO_ROOTFS_TYPE ?= "squashfs" + IMAGER_BUILD_DEPS:append = " dosfstools-native" IMAGER_BUILD_DEPS:remove:buster = "dosfstools-native"
kas/opt/swupdate.yml +4 -4
@@ -1,7 +1,7 @@ # # CIP Core, generic profile # -# Copyright (c) Siemens AG, 2020 +# Copyright (c) Siemens AG, 2020-2024 # # Authors: # Quirin Gylstorff <[email protected]>
@@ -20,12 +20,12 @@ local_conf_header: OVERRIDES .= ":swupdate" wic-swu: | - IMAGE_TYPEDEP:wic += "squashfs" + IMAGE_TYPEDEP:wic += "${RO_ROOTFS_TYPE}" IMAGE_FSTYPES:append = " swu" - # squashfs is already compressed + # input is already compressed SWU_COMPRESSION_TYPE = "" WKS_FILE ?= "${MACHINE}-${SWUPDATE_BOOTLOADER}.wks.in" - INITRAMFS_INSTALL:append = " initramfs-squashfs-hook" + INITRAMFS_INSTALL:append = " initramfs-${RO_ROOTFS_TYPE}-hook" ABROOTFS_PART_UUID_A ?= "fedcba98-7654-3210-cafe-5e0710000001" ABROOTFS_PART_UUID_B ?= "fedcba98-7654-3210-cafe-5e0710000002" PREFERRED_PROVIDER_swupdate-certificates-key ??= "swupdate-certificates-key-snakeoil"
wic/bbb-efibootguard.wks.in +1 -1
@@ -11,7 +11,7 @@ part --source rawcopy --sourceparams "file=/usr/lib/u-boot/bbb/u-boot.img" --no- include ebg-sysparts.inc -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --part-name systema +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.${RO_ROOTFS_TYPE}" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --part-name systema part --source empty --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B}" --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --part-name systemb # home and var are extra partitions
wic/hihope-rzg2m-efibootguard.wks.in +1 -1
@@ -3,7 +3,7 @@ include ebg-sysparts.inc -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --part-name systema +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.${RO_ROOTFS_TYPE}" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --part-name systema part --source empty --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B}" --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --part-name systemb # home and var are extra partitions
wic/qemu-arm64-efibootguard.wks.in +1 -1
@@ -3,7 +3,7 @@ include ebg-sysparts.inc -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --part-name systema +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.${RO_ROOTFS_TYPE}" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --part-name systema part --source empty --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B}" --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --part-name systemb # home and var are extra partitions
wic/qemu-riscv64-efibootguard.wks.in +1 -1
@@ -3,7 +3,7 @@ include ebg-sysparts.inc -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --part-name systema +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.${RO_ROOTFS_TYPE}" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --part-name systema part --source empty --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B}" --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --part-name systemb # home and var are extra partitions
wic/x86-uefi-efibootguard.wks.in +1 -1
@@ -3,7 +3,7 @@ include ebg-sysparts.inc -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --part-name systema +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.${RO_ROOTFS_TYPE}" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --part-name systema part --source empty --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B}" --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --part-name systemb # home and var are extra partitions
Signature · 1 line
2.43.0
PATCH 2/6 initramfs-crypt-hook: Prepare for EROFS as alternative
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Naturally, expansion does not make sense for it as well.
---
.../initramfs-crypt-hook/files/encrypt_partition.script | 2 +-
...{initramfs-crypt-hook_0.2.bb => initramfs-crypt-hook_0.3.bb} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename recipes-initramfs/initramfs-crypt-hook/{initramfs-crypt-hook_0.2.bb => initramfs-crypt-hook_0.3.bb} (100%)recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.script +1 -1
@@ -82,7 +82,7 @@ EOF panic "reencryption of filesystem $1 cannot continue!" fi ;; - squashfs|swap|"") + squashfs|swap|erofs|"") [ "$debug" = "y" ] && echo "skip disk resize as it is not supported or unnecessary for fstype: '$partition_fstype'" ;; *)
recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.3.bb renamed from recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.2.bb +0 -0
Signature · 1 line
2.43.0
PATCH 3/6 Add initramfs-erofs-hook
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This is basically just search&replace compared to
initramfs-squashfs-hook.
--- .../initramfs-erofs-hook/files/erofs.hook | 25 +++++++++++++++++++ .../initramfs-erofs-hook_0.1.bb | 24 ++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 recipes-initramfs/initramfs-erofs-hook/files/erofs.hook create mode 100644 recipes-initramfs/initramfs-erofs-hook/initramfs-erofs-hook_0.1.bb
recipes-initramfs/initramfs-erofs-hook/files/erofs.hook new file +25 -0
@@ -0,0 +1,25 @@ +#!/bin/sh +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2024 +# +# Authors: +# Jan Kiszka <[email protected]> +# + +PREREQ="" +prereqs() +{ + echo "$PREREQ" +} +case $1 in +prereqs) + prereqs + exit 0 + ;; +esac + +. /usr/share/initramfs-tools/hook-functions + +manual_add_modules erofs
recipes-initramfs/initramfs-erofs-hook/initramfs-erofs-hook_0.1.bb new file +24 -0
@@ -0,0 +1,24 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2024 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +inherit dpkg-raw + +SRC_URI += "file://erofs.hook" + +DEBIAN_DEPENDS = "erofs-utils" + +do_install[cleandirs] += " \ + ${D}/usr/share/initramfs-tools/hooks" + +do_install() { + install -m 0755 "${WORKDIR}/erofs.hook" \ + "${D}/usr/share/initramfs-tools/hooks/erofs" +}
Signature · 1 line
2.43.0
PATCH 4/6 Introduce class for generating EROFS images
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This is analogous to the squashfs class.
--- classes/erofs.bbclass | 34 ++++++++++++++++++++++++++++++++++ conf/layer.conf | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 classes/erofs.bbclass
classes/erofs.bbclass new file +34 -0
@@ -0,0 +1,34 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2024 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +IMAGER_INSTALL:erofs += "erofs-utils" + +EROFS_EXCLUDE_DIRS ?= "" +EROFS_CONTENT ?= "${PP_ROOTFS}" +EROFS_CREATION_ARGS ?= "-z lz4hc,12" + +python __anonymous() { + exclude_directories = d.getVar('EROFS_EXCLUDE_DIRS').split() + if len(exclude_directories) == 0: + return + # Use regex to exclude only content of the directory. + # This allows to use the directory as a mount point. + for dir in exclude_directories: + args += " --exclude-regex {dir}/.* ".format(dir=dir) + d.appendVar('EROFS_CREATION_ARGS', args) +} + +IMAGE_CMD:erofs[depends] = "${PN}:do_transform_template" +IMAGE_CMD:erofs() { + ${SUDO_CHROOT} /bin/mkfs.erofs \ + '${IMAGE_FILE_CHROOT}' '${EROFS_CONTENT}' \ + ${EROFS_CREATION_ARGS} +}
conf/layer.conf +1 -1
@@ -23,5 +23,5 @@ LAYERSERIES_COMPAT_cip-core = "next" LAYERDIR_cip-core = "${LAYERDIR}" LAYERDIR_cip-core[vardepvalue] = "isar-cip-core" -IMAGE_CLASSES += "squashfs verity swupdate delta-update" +IMAGE_CLASSES += "squashfs erofs verity swupdate delta-update"
Signature · 1 line
2.43.0
PATCH 5/6 linux-cip: Update cip-kernel-config revision
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This brings support for EROFS and PID namespaces for 6.1 and also fixes Ethernet configuration on BeagleBone Black.
--- recipes-kernel/linux/cip-kernel-config.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
recipes-kernel/linux/cip-kernel-config.inc +1 -1
@@ -14,6 +14,6 @@ SRC_URI:append = " ${@ \ if d.getVar('USE_CIP_KERNEL_CONFIG') == '1' else '' \ }" -SRCREV_cip-kernel-config ?= "f6b7018cb6845f34f8a03c126bf4f823ce10d637" +SRCREV_cip-kernel-config ?= "c3c5f08d24dc05f7dd20d29d6337e00aad190093" do_fetch[vardeps] += "SRCREV_cip-kernel-config"
Signature · 1 line
2.43.0
Re: [isar-cip-core][PATCH 5/6] linux-cip: Update cip-kernel-config revision
Quoted 15 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
This brings support for EROFS and PID namespaces for 6.1 and also fixes Ethernet configuration on BeagleBone Black.
Signed-off-by Jan Kiszka <[email protected]>--- recipes-kernel/linux/cip-kernel-config.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)recipes-kernel/linux/cip-kernel-config.inc +0
-0
recipes-kernel/linux/cip-kernel-config.inc SRC_URI:append = " ${@ \ · line 19
Quoted 7 lines
recipes-kernel/linux/cip-kernel-config.inc +1
-1@@ -14,6 +14,6 @@ SRC_URI:append = " ${@ \ if d.getVar('USE_CIP_KERNEL_CONFIG') == '1' else '' \ }" -SRCREV_cip-kernel-config ?= "f6b7018cb6845f34f8a03c126bf4f823ce10d637" +SRCREV_cip-kernel-config ?= "c3c5f08d24dc05f7dd20d29d6337e00aad190093" do_fetch[vardeps] += "SRCREV_cip-kernel-config"
Ok, this will need a v2 once [1] is merged. Or [2] is resolved so that it can be merged.
Jan
[1] https://gitlab.com/cip-project/cip-kernel/cip-kernel-config/-/merge_requests/106
[2] https://lore.kernel.org/cip-dev/[email protected]/
Signature · 2 lines
Siemens AG, Technology Linux Expert Center
PATCH 6/6 kas: Add option for selecting read-only rootfs type
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This allows to select EROFS as alternative to squashfs. The option is limited to 6.1 kernels, older ones will no longer be enabled.
--- Kconfig | 16 ++++++++++++++++ kas/opt/erofs.yml | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 kas/opt/erofs.yml
Kconfig +16 -0
@@ -198,6 +198,22 @@ config IMAGE_DELTA_SWUPDATE endchoice +choice + prompt "Read-only rootfs type" + +config IMAGE_RO_ROOTFS_SQUASHFS + bool "Squashfs" + +config IMAGE_RO_ROOTFS_EROFS + bool "EROFS" + depends on KERNEL_6_1 + +endchoice + +config KAS_INCLUDE_EROFS + string + default "kas/opt/erofs.yml" if IMAGE_RO_ROOTFS_EROFS + config IMAGE_SECURE_BOOT bool "Secure boot support" depends on TARGET_QEMU_AMD64 || TARGET_QEMU_ARM64 || TARGET_QEMU_ARM || TARGET_X86_UEFI
kas/opt/erofs.yml new file +16 -0
@@ -0,0 +1,16 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2024 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT + +header: + version: 14 + +local_conf_header: + erofs: | + RO_ROOTFS_TYPE = "erofs"
Signature · 1 line
2.43.0