[PATCH v2 6/7] host/rootfs: run transient VMs with persistence

Alyssa Ross
2025-12-14T01:48:15Z

This allows run-appimage and run-flatpak to be given the name of a
previously saved persistent directory. Further writes by the
application to that directory will also be persisted.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
---
v2: new this round

host/rootfs/image/usr/bin/run-appimage | 16 +++++++++++++---
host/rootfs/image/usr/bin/run-flatpak | 15 +++++++++++++--
2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/host/rootfs/image/usr/bin/run-appimage b/host/rootfs/image/usr/bin/run-appimage
index de851c52..24621065 100755
--- a/host/rootfs/image/usr/bin/run-appimage
+++ b/host/rootfs/image/usr/bin/run-appimage
@@ -26,13 +26,23 @@ if {
}

backtick diskdir {
- s6-setuidgid fs
-
- backtick -E mountpoint {
+ backtick mountpoint {
importas -Siu 1
findmnt -no TARGET -T $1
}

+ if -tn {
+ redirfd -w 2 /dev/null
+ multisubstitute {
+ importas -Siu mountpoint
+ importas -Siu 2
+ }
+ printf "%s/Spectrum/data/spectrum/storage/persist.%s\n" $mountpoint $2
+ }
+
+ s6-setuidgid fs
+
+ importas -Siu mountpoint
if { mkdir -p -- ${mountpoint}/Spectrum/data/spectrum/storage }
mktemp -d -- ${mountpoint}/Spectrum/data/spectrum/storage/tmp.XXXXXX
}
diff --git a/host/rootfs/image/usr/bin/run-flatpak b/host/rootfs/image/usr/bin/run-flatpak
index b47204c9..4123d329 100755
--- a/host/rootfs/image/usr/bin/run-flatpak
+++ b/host/rootfs/image/usr/bin/run-flatpak
@@ -26,6 +26,15 @@ if {
}

backtick diskdir {
+ if -tn {
+ redirfd -w 2 /dev/null
+ multisubstitute {
+ importas -Siu 1
+ importas -Siu 4
+ }
+ printf "%s/Spectrum/data/spectrum/storage/persist.%s\n" $1 $4
+ }
+
s6-setuidgid fs

importas -Siu 1
@@ -41,7 +50,9 @@ if {
multisubstitute {
importas -Siu id
importas -Siu diskdir
- elgetpositionals
+ importas -Siu 1
+ importas -Siu 2
+ importas -Siu 3
}

nsenter --preserve-credentials -S0
@@ -50,7 +61,7 @@ if {

cd /run/fs/${id}/config
if { redirfd -w 1 type echo flatpak }
- if { mount-flatpak $@ }
+ if { mount-flatpak $1 $2 $3 }

mount --bind -- $diskdir /run/fs/${id}/disk
}
--
2.51.0