From 4993c83bcb9f78a1db246b348c5402fb93ea8897 Mon Sep 17 00:00:00 2001 From: Jan Luebbe Date: Wed, 27 May 2015 22:50:30 +0200 Subject: [PATCH] initramfs-rauc-slot: add recipe to boot a slot using aufs2 This uses the "initramfs-framework" from oe-core. Signed-off-by: Jan Luebbe --- .../initrdscripts/initramfs-rauc-slot.bb | 31 ++++++++++++++ .../initrdscripts/initramfs-rauc-slot/overlay | 42 +++++++++++++++++++ .../initrdscripts/initramfs-rauc-slot/rescue | 13 ++++++ 3 files changed, 86 insertions(+) create mode 100644 recipes-core/initrdscripts/initramfs-rauc-slot.bb create mode 100644 recipes-core/initrdscripts/initramfs-rauc-slot/overlay create mode 100644 recipes-core/initrdscripts/initramfs-rauc-slot/rescue diff --git a/recipes-core/initrdscripts/initramfs-rauc-slot.bb b/recipes-core/initrdscripts/initramfs-rauc-slot.bb new file mode 100644 index 0000000..62c96d5 --- /dev/null +++ b/recipes-core/initrdscripts/initramfs-rauc-slot.bb @@ -0,0 +1,31 @@ +SUMMARY = "Modular initramfs system components for RAUC" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" + +PR = "r0" + +inherit allarch + +SRC_URI = "file://overlay \ + file://rescue" + +do_install() { + install -d ${D}/init.d + + # overlay + install -m 0755 ${WORKDIR}/overlay ${D}/init.d/20-overlay + + # rescue + install -m 0755 ${WORKDIR}/rescue ${D}/init.d/10-rescue +} + +PACKAGES = "initramfs-module-rauc-overlay \ + initramfs-module-rauc-rescue" + +SUMMARY_initramfs-module-rauc-overlay = "initramfs support for overlayfs (ubifs&squashfs)" +RDEPENDS_initramfs-module-rauc-overlay = "initramfs-framework-base" +FILES_initramfs-module-rauc-overlay = "/init.d/20-overlay" + +SUMMARY_initramfs-module-rauc-rescue = "initramfs rescue mode support" +RDEPENDS_initramfs-module-rauc-rescue = "initramfs-framework-base" +FILES_initramfs-module-rauc-rescue = "/init.d/10-rescue" diff --git a/recipes-core/initrdscripts/initramfs-rauc-slot/overlay b/recipes-core/initrdscripts/initramfs-rauc-slot/overlay new file mode 100644 index 0000000..b1260f6 --- /dev/null +++ b/recipes-core/initrdscripts/initramfs-rauc-slot/overlay @@ -0,0 +1,42 @@ +#!/bin/sh + +overlay_enabled() { + return 0 +} + +overlay_run() { + info "Mounting slot..." + mkdir /slot + if [ -z "$bootparam_root" ]; then + fatal "ERROR: No root device was provided." + fi + mount -o ro $bootparam_root /slot || fatal "Failed!" + info "Mounting squashfs..." + mkdir /ro-root + mount -t squashfs -o loop=/dev/loop0,ro /slot/rootfs.squashfs /ro-root || fatal "Failed!" + info "Mounting tmpfs..." + mkdir /rw-root + mount -t tmpfs -o size=25%,mode=1777,uid=0,gid=0,rw tmpfs /rw-root || fatal "Failed!" + if grep -q aufs /proc/filesystems; then + info "Mounting aufs..." + mount -t aufs -o br=/rw-root:/ro-root aufs /rootfs || fatal "Failed!" + else + info "Mounting overlayfs..." + mkdir /rw-root/root + mkdir /rw-root/work + mount -t overlayfs -o lowerdir=/ro-root,upperdir=/rw-root/root,workdir=/rw-root/work overlayfs /rootfs || fatal "Failed!" + fi + if [ -e /slot/overlay.tar.bz2 ]; then + info "Extracting overlay..." + tar xf /slot/overlay.tar.bz2 -C /rootfs || fatal "Failed!" + fi + info "Moving overlay components..." + mkdir /rootfs/slot + mkdir /rootfs/ro-root + mkdir /rootfs/rw-root + mount --move /slot /rootfs/slot + mount --move /ro-root /rootfs/ro-root + mount --move /rw-root /rootfs/rw-root + # rootfs is already handled + bootparam_root= +} diff --git a/recipes-core/initrdscripts/initramfs-rauc-slot/rescue b/recipes-core/initrdscripts/initramfs-rauc-slot/rescue new file mode 100644 index 0000000..3ce0745 --- /dev/null +++ b/recipes-core/initrdscripts/initramfs-rauc-slot/rescue @@ -0,0 +1,13 @@ +#!/bin/sh + +rescue_enabled() { + if [ ! -f "/sbin/init" ]; then + return 1 + fi + return 0 +} + +rescue_run() { + info "Starting /sbin/init..." + exec /sbin/init +}