aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-07-01 06:21:25 +0200
committerSven Gothel <[email protected]>2021-07-01 06:21:25 +0200
commit81dc51e171a542f2534e9a3cb8c9bfbe6245a83b (patch)
tree3a9a94c14e9be8d5dfd9e535efc4fdfcd3c0f977
parentf44f5a676b1c621f451550d77ed0ce75d5696dce (diff)
ro: Move overlay handling stage1 -> stage2 (creation, as overlay_mount is located there already)
-rwxr-xr-xstage1/01-sys-tweaks/00-run.sh11
-rw-r--r--stage1/01-sys-tweaks/files/fstab6
-rwxr-xr-xstage2/01-sys-tweaks/01-run.sh14
-rwxr-xr-xstage2/01-sys-tweaks/files/overlay_mount19
4 files changed, 28 insertions, 22 deletions
diff --git a/stage1/01-sys-tweaks/00-run.sh b/stage1/01-sys-tweaks/00-run.sh
index 174b98f..03ad686 100755
--- a/stage1/01-sys-tweaks/00-run.sh
+++ b/stage1/01-sys-tweaks/00-run.sh
@@ -5,17 +5,6 @@ install -m 644 files/noclear.conf "${ROOTFS_DIR}/etc/systemd/system/[email protected]
install -v -m 644 files/fstab "${ROOTFS_DIR}/etc/fstab"
on_chroot << EOF
-mkdir -p /data/etc/upper
-mkdir -p /data/etc/work
-mkdir -p /data/home/upper
-mkdir -p /data/home/work
-mkdir -p /data/srv/upper
-mkdir -p /data/srv/work
-mkdir -p /data/tmp/upper
-mkdir -p /data/tmp/work
-mkdir -p /data/var/upper
-mkdir -p /data/var/work
-
# Memory ~1G -> Swap 2G; BUT slow and small sd-card
# Use 200MB (Raspberry comes with 100MB default)
rm -f /data/swapfile
diff --git a/stage1/01-sys-tweaks/files/fstab b/stage1/01-sys-tweaks/files/fstab
index e99264c..6761eaf 100644
--- a/stage1/01-sys-tweaks/files/fstab
+++ b/stage1/01-sys-tweaks/files/fstab
@@ -7,10 +7,4 @@ ROOTDEV / ext4 defaults,noatime,ro,errors=remount-ro 0
/data/swapfile none swap defaults 0 0
# defaults = rw, suid, dev, exec, auto, nouser, and async
-# we replace auto -> noauto,x-systemd.automount
-#overlay /etc overlay noauto,x-systemd.automount,rw,suid,dev,exec,nouser,async,noatime,lowerdir=/etc,upperdir=/data/etc/upper,workdir=/data/etc/work 0 0
-#overlay /home overlay noauto,x-systemd.automount,rw,suid,dev,exec,nouser,async,noatime,lowerdir=/home,upperdir=/data/home/upper,workdir=/data/home/work 0 0
-#overlay /srv overlay noauto,x-systemd.automount,rw,suid,dev,exec,nouser,async,noatime,lowerdir=/srv,upperdir=/data/srv/upper,workdir=/data/srv/work 0 0
-#overlay /tmp overlay noauto,x-systemd.automount,rw,suid,dev,exec,nouser,async,noatime,lowerdir=/tmp,upperdir=/data/tmp/upper,workdir=/data/tmp/work 0 0
-#overlay /var overlay noauto,x-systemd.automount,rw,suid,dev,exec,nouser,async,noatime,lowerdir=/var,upperdir=/data/var/upper,workdir=/data/var/work 0 0
diff --git a/stage2/01-sys-tweaks/01-run.sh b/stage2/01-sys-tweaks/01-run.sh
index ff5bc4d..139154a 100755
--- a/stage2/01-sys-tweaks/01-run.sh
+++ b/stage2/01-sys-tweaks/01-run.sh
@@ -36,6 +36,20 @@ else
systemctl disable ssh
fi
systemctl enable regenerate_ssh_host_keys
+
+mkdir -p /data/overlay_a
+cd /data/overlay_a
+mkdir -p etc/upper etc/work home/upper home/work srv/upper srv/work tmp/upper tmp/work var/upper var/work
+
+mkdir -p /data/overlay_b
+cd /data/overlay_b
+mkdir -p etc/upper etc/work home/upper home/work srv/upper srv/work tmp/upper tmp/work var/upper var/work
+
+cd /data
+ln -s overlay_a overlay
+
+systemctl enable overlay_mount
+
EOF
if [ "${USE_QEMU}" = "1" ]; then
diff --git a/stage2/01-sys-tweaks/files/overlay_mount b/stage2/01-sys-tweaks/files/overlay_mount
index f2e7e1e..0ecbcce 100755
--- a/stage2/01-sys-tweaks/files/overlay_mount
+++ b/stage2/01-sys-tweaks/files/overlay_mount
@@ -12,11 +12,20 @@ case "$1" in
start)
log_daemon_msg "Starting overlay_mount"
/bin/mount -t ext4 DATADEV -odefaults,noatime /data &&
- /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/etc,upperdir=/data/etc/upper,workdir=/data/etc/work /etc &&
- /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/home,upperdir=/data/home/upper,workdir=/data/home/work /home &&
- /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/srv,upperdir=/data/srv/upper,workdir=/data/srv/work /srv &&
- /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/tmp,upperdir=/data/tmp/upper,workdir=/data/tmp/work /tmp &&
- /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/var,upperdir=/data/var/upper,workdir=/data/var/work /var &&
+ if [ -f /data/overlay/ERASE ]; then \
+ log_progress_msg "erasing overlay" ; \
+ rm -f /data/overlay/ERASE ; \
+ cd /data/overlay ; \
+ rm -rf etc home srv tmp var ; \
+ mkdir -p etc/upper etc/work home/upper home/work srv/upper srv/work tmp/upper tmp/work var/upper var/work ; \
+ else \
+ log_progress_msg "keeping overlay" ; \
+ fi &&
+ /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/etc,upperdir=/data/overlay/etc/upper,workdir=/data/overlay/etc/work /etc &&
+ /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/home,upperdir=/data/overlay/home/upper,workdir=/data/overlay/home/work /home &&
+ /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/srv,upperdir=/data/overlay/srv/upper,workdir=/data/overlay/srv/work /srv &&
+ /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/tmp,upperdir=/data/overlay/tmp/upper,workdir=/data/overlay/tmp/work /tmp &&
+ /bin/mount -t overlay overlay -odefaults,noatime,lowerdir=/var,upperdir=/data/overlay/var/upper,workdir=/data/overlay/var/work /var &&
log_end_msg $?
;;
*)