Add support for znx overlays.
znx
specifies a scheme for allowing the user to save data in the storage device. The initramfs is responsible for mounting whichever directories the user requests with the OVERLAYFS
driver (thus, allowing data persistence between reboots).
I'm unable to fork the project, so I had to write the solutions here.
One file should be added, and one altered.
A new initramfs hook: miso_znx_overlays
.
mnt_znx_overlays () {
# Persistent storage directory.
zpd=/run/miso/img_dev/${img_loop%/*}/DATA
# Mount the requested overlays.
for k in $(printf "$ZNX_OVERLAYS" | sed 's/,/ /g'); do
mkdir -p \
$1/$k \
$zpd/$k \
$zpd/.znx-tmp/$k.w
mount -t overlay \
-o lowerdir=$1/$k \
-o upperdir=$zpd/$k \
-o workdir=$zpd/.znx-tmp/$k.w \
. $1/$k
done
}
znx_mount_handler () {
newroot="$1"
miso_loop_mount_handler $newroot
[ "$ZNX_OVERLAYS" ] &&
mnt_znx_overlays $newroot
}
run_hook () {
[ "$copytoram" == "y" -a "$ZNX_OVERLAYS" ] && {
echo "WARNING: 'copytoram' is set. znx overlays will not be available."
return
}
[ "$img_loop" -a "$ZNX_OVERLAYS" ] && {
img_dev=$(find_dev_by_path "$img_loop")
mount_handler="znx_mount_handler"
}
}
That hook should be specified in /etc/mkinitcpio.conf
:
MODULES=(loop dm-snapshot)
HOOKS=(base udev miso miso_shutdown miso_loop_mnt miso_znx_overlays miso_pxe_common miso_pxe_http miso_pxe_nbd miso_pxe_nfs miso_kms modconf block filesystems keyboard keymap)
COMPRESSION=xz
Those are all the changes needed to enable data persistence in the ISO images.