initramfs-rauc-slot: add recipe to boot a slot using aufs2

This uses the "initramfs-framework" from oe-core.

Signed-off-by: Jan Luebbe <jluebbe@debian.org>
This commit is contained in:
Jan Luebbe 2015-05-27 22:50:30 +02:00 committed by Holger Hans Peter Freyther
parent 2ec9d6401d
commit 4993c83bcb
3 changed files with 86 additions and 0 deletions

View File

@ -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"

View File

@ -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=
}

View File

@ -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
}