From ed323de4dcb600dd71d544f5994f52307b6db564 Mon Sep 17 00:00:00 2001 From: Alejandro Hernandez Samaniego Date: Sat, 29 Jan 2022 12:48:39 -0700 Subject: initramfs-framework: Add overlayroot module When installed, this module mounts a read-write (RW) overlay on top of a root filesystem, which is kept read-only (RO), free from modifications by the user, this might prove to be useful if we want to access or restore the original unmodified rootfs. The existing overlay-etc.bbclass does something similar, it mounts an overlay on top of the /etc directory, however doing the same for root causes the original root to be inaccessible once the system is booted, hence why this module is added to the initramfs boot flow, allowing us to mount the RW overlay, while keeping the original rootfs mounted at /rofs once the system finishes booting. This script is loosely based on that class. This module requires rootrw= to be passed as a kernel parameter to specify the device/partition to be used as RW by the overlay and has a dependency on overlayfs support being present in the running kernel. It does not require the read-only IMAGE_FEATURE to be enabled. The module needs to be executed after the initramfs-module-rootfs since it relies on it to mount the filesystem at initramfs startup but before the finish module which normally switches root. After overlayroot is executed the usual boot flow continues from the real init process. If something goes wrong while running this module, the rootfs is still mounted RO (with no overlay) and the finish module is executed to continue booting normally. Its worth noting that, on purpose, this isnt installed by default on any images that use initramfs-framework to keep the boot flow unmodified, only when a user manually requests to install it, then it becomes functional. (From OE-Core rev: 4f876982a856c54a8074c85346632e33caa7ef53) Signed-off-by: Alejandro Enedino Hernandez Samaniego Signed-off-by: Richard Purdie --- meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb') diff --git a/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb b/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb index 9e8c1dc3ab..4e76e20026 100644 --- a/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb +++ b/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb @@ -18,6 +18,7 @@ SRC_URI = "file://init \ file://e2fs \ file://debug \ file://lvm \ + file://overlayroot \ " S = "${WORKDIR}" @@ -49,6 +50,9 @@ do_install() { # lvm install -m 0755 ${WORKDIR}/lvm ${D}/init.d/09-lvm + # overlayroot needs to run after rootfs module but before finish + install -m 0755 ${WORKDIR}/overlayroot ${D}/init.d/91-overlayroot + # Create device nodes expected by some kernels in initramfs # before even executing /init. install -d ${D}/dev @@ -64,6 +68,7 @@ PACKAGES = "${PN}-base \ initramfs-module-rootfs \ initramfs-module-debug \ initramfs-module-lvm \ + initramfs-module-overlayroot \ " FILES:${PN}-base = "/init /init.d/99-finish /dev" @@ -107,3 +112,7 @@ FILES:initramfs-module-debug = "/init.d/00-debug" SUMMARY:initramfs-module-lvm = "initramfs lvm rootfs support" RDEPENDS:initramfs-module-lvm = "${PN}-base" FILES:initramfs-module-lvm = "/init.d/09-lvm" + +SUMMARY:initramfs-module-overlayroot = "initramfs support for mounting a RW overlay on top of a RO root filesystem" +RDEPENDS:initramfs-module-overlayroot = "${PN}-base initramfs-module-rootfs" +FILES:initramfs-module-overlayroot = "/init.d/91-overlayroot" -- cgit v1.2.3-54-g00ecf