From b4bd858a6e81707518dd3b42b02dd6e2eca3a071 Mon Sep 17 00:00:00 2001 From: Denis Benato Date: Sat, 27 Jul 2024 17:11:04 +0200 Subject: [PATCH] fix /root directory still being readonly after unlocking the filesystem --- build-image.sh | 1 + rootfs/usr/lib/frzr.d/install-0004-overlays.migration | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/build-image.sh b/build-image.sh index df85af4a5..d6556e710 100755 --- a/build-image.sh +++ b/build-image.sh @@ -174,6 +174,7 @@ Subsystem sftp /usr/lib/ssh/sftp-server echo " LABEL=frzr_root /frzr_root btrfs defaults,x-initrd.mount,subvolid=5,rw,noatime,nodatacow 0 2 LABEL=frzr_root /home btrfs defaults,x-systemd.rw-only,subvol=/home,rw,noatime,nodatacow,nofail 0 0 +overlay /root overlay defaults,x-systemd.requires-mounts-for=/frzr_root,x-systemd.requires-mounts-for=/sysroot/frzr_root,x-initrd.mount,lowerdir=/sysroot/root,upperdir=/sysroot/frzr_root/deployments_data/${SYSTEM_NAME}-${VERSION}/root_overlay/upperdir,workdir=/sysroot/frzr_root/deployments_data/${SYSTEM_NAME}-${VERSION}/root_overlay/workdir,index=off,metacopy=off,xino=off,redirect_dir=off,comment=rootoverlay 0 0 overlay /boot overlay defaults,x-systemd.requires-mounts-for=/frzr_root,x-systemd.requires-mounts-for=/sysroot/frzr_root,x-initrd.mount,lowerdir=/sysroot/frzr_root/kernels/boot:/sysroot/frzr_root/device_quirks/${SYSTEM_NAME}-${VERSION}/boot:/sysroot/boot,upperdir=/sysroot/frzr_root/deployments_data/${SYSTEM_NAME}-${VERSION}/boot_overlay/upperdir,workdir=/sysroot/frzr_root/deployments_data/${SYSTEM_NAME}-${VERSION}/boot_overlay/workdir,index=off,metacopy=off,xino=off,redirect_dir=off,comment=bootoverlay 0 0 overlay /usr overlay defaults,x-systemd.requires-mounts-for=/frzr_root,x-systemd.requires-mounts-for=/sysroot/frzr_root,x-initrd.mount,lowerdir=/sysroot/frzr_root/kernels/usr:/sysroot/frzr_root/device_quirks/${SYSTEM_NAME}-${VERSION}/usr:/sysroot/usr,upperdir=/sysroot/frzr_root/deployments_data/${SYSTEM_NAME}-${VERSION}/usr_overlay/upperdir,workdir=/sysroot/frzr_root/deployments_data/${SYSTEM_NAME}-${VERSION}/usr_overlay/workdir,index=off,metacopy=off,xino=off,redirect_dir=off,comment=usroverlay 0 0 overlay /etc overlay defaults,x-systemd.requires-mounts-for=/frzr_root,x-systemd.requires-mounts-for=/sysroot/frzr_root,x-initrd.mount,x-systemd.rw-only,lowerdir=/sysroot/frzr_root/kernels/etc:/sysroot/frzr_root/device_quirks/${SYSTEM_NAME}-${VERSION}/etc:/sysroot/etc,upperdir=/sysroot/frzr_root/deployments_data/${SYSTEM_NAME}-${VERSION}/etc_overlay/upperdir,workdir=/sysroot/frzr_root/deployments_data/${SYSTEM_NAME}-${VERSION}/etc_overlay/workdir,index=off,metacopy=off,xino=off,redirect_dir=off,comment=etcoverlay 0 0 diff --git a/rootfs/usr/lib/frzr.d/install-0004-overlays.migration b/rootfs/usr/lib/frzr.d/install-0004-overlays.migration index 8a8084f37..866f666cb 100755 --- a/rootfs/usr/lib/frzr.d/install-0004-overlays.migration +++ b/rootfs/usr/lib/frzr.d/install-0004-overlays.migration @@ -33,12 +33,12 @@ post_install() { # clear the old /usr overlay if [ -d "${SUBVOL_DATA}/usr_overlay" ]; then - rm -rf "${SUBVOL_DATA}/usr_overlay" + rmdir "${SUBVOL_DATA}/usr_overlay" fi # clear the old /boot overlay if [ -d "${SUBVOL_DATA}/boot_overlay" ]; then - rm -rf "${SUBVOL_DATA}/boot_overlay" + rmdir "${SUBVOL_DATA}/boot_overlay" fi else echo "No previous overlay found: creating the overlay" @@ -52,6 +52,9 @@ post_install() { mkdir -p "${SUBVOL_DATA}/etc_overlay/workdir" mkdir -p "${SUBVOL_DATA}/var_overlay/upperdir" mkdir -p "${SUBVOL_DATA}/var_overlay/workdir" + mkdir -p "${SUBVOL_DATA}/root_overlay" + mkdir -p "${SUBVOL_DATA}/root_overlay/upperdir" + mkdir -p "${SUBVOL_DATA}/root_overlay/workdir" btrfs subvol create "${SUBVOL_DATA}/usr_overlay" mkdir "${SUBVOL_DATA}/usr_overlay/upperdir" mkdir "${SUBVOL_DATA}/usr_overlay/workdir" @@ -62,7 +65,7 @@ post_install() { btrfs property set -fts "${SUBVOL_DATA}/usr_overlay" ro true btrfs property set -fts "${SUBVOL_DATA}/boot_overlay" ro true - if [ ! -d "${MOUNT_PATH}/usr" ] && [ -d "${MOUNT_PATH}/etc" ] && [ -z $sysroot_snapshot ] && [ -d "${MOUNT_PATH}/.etc" ] && [ -z $sysroot_snapshot ]; then + if [ ! -d "${MOUNT_PATH}/usr" ] && [ -d "${MOUNT_PATH}/etc" ] && [ -z "$sysroot_snapshot" ] && [ -d "${MOUNT_PATH}/.etc" ]; then echo "Cloning the /etc overlay upperdir from '${MOUNT_PATH}/etc/' to '${SUBVOL_DATA}/etc_overlay/upperdir'..." cp -a "${MOUNT_PATH}/etc" "${SUBVOL_DATA}/etc_overlay/" rm -rf "${SUBVOL_DATA}/etc_overlay/upperdir" @@ -90,4 +93,6 @@ post_install() { echo "Clearing up pacman old pacman gnupg overlay in '${SUBVOL_DATA}/etc_overlay/upperdir/pacman.d/gnupg'..." rm -rf "${SUBVOL_DATA}/etc_overlay/upperdir/pacman.d/gnupg" fi + + echo "OK" } \ No newline at end of file