mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-03 06:13:02 +02:00
board/common: mnt: Correctly reset /var as part of a factory-reset
Before this change, the following would happen in /lib/infix/mnt if a factory-reset was performed: 1. Copy the contents of /var from Squash into /mnt/var and bind mount /mnt/var over /var 2. Check for factory-reset 3. Clear /mnt/cfg/* and /mnt/var/* 4. Mount overlays This ordering leaves the system with a completely empty /var on the boot when a factory-reset is executed. Finit will fixup some of this via its tmpfiles scripts, but we want the ability to ship files under /var as part of the Squash and have these be available after the bind mount, just like what happens at every other boot, when we don't perform a factory-reset. We solve this by delaying the bind mount (1) until after the reset has been performed, together with all the overlays (4). While we're here, make the fallback case, where no persistent /var is available, use a bind mount as well. This should allow containers to be tested on such setups, and it's one less flavor to test. New order: 1. Check for factory-reset 2. Clear /mnt/cfg/* and /mnt/var/* 3. Mount overlays 4. Copy the contents of /var from Squash into /mnt/var and bind mount /mnt/var over /var Now the only difference between a regular boot and a "factory-reset-boot" is whether (2) executed or not.
This commit is contained in:
committed by
Joachim Wiberg
parent
5db84ddec6
commit
2bfc524546
@@ -109,12 +109,8 @@ varsrc=/mnt/var
|
||||
if ! mount_rw var >/dev/null 2>&1; then
|
||||
logger $opt -p user.warn -t "$nm" \
|
||||
"No persistent storage found for /var, only /var/lib is persisted."
|
||||
varsrc=/mnt/tmp
|
||||
varsrc=/mnt/tmp/infix/var
|
||||
vlibsrc=/mnt/cfg/vlib
|
||||
else
|
||||
mount_bind "$varsrc" /var
|
||||
varsrc=
|
||||
vlibsrc=
|
||||
fi
|
||||
|
||||
cfgsrc=/mnt/cfg
|
||||
@@ -145,9 +141,9 @@ mount_overlay cfg $cfgsrc /cfg
|
||||
mount_overlay etc $etcsrc /etc
|
||||
mount_overlay home $cfgsrc /home
|
||||
mount_overlay root $cfgsrc /root
|
||||
mount_bind "$varsrc" /var
|
||||
|
||||
[ "$varsrc" ] && mount_overlay var "$varsrc" /var
|
||||
[ "$vlibsrc" ] && mount_bind "$vlibsrc" /var/lib
|
||||
[ "$vlibsrc" ] && mount_bind "$vlibsrc" /var/lib
|
||||
|
||||
# Keep transient configs in a ramdisk and symlink out to /cfg for
|
||||
# startup.
|
||||
|
||||
Reference in New Issue
Block a user