I've been messing around with initrd. Opened up the initrd using Easy and dropped the q.sfs into that. The following code aufs mounts that 'internal' q.sfs, formed as a aufs union of the q.sfs (ro) and a q_changes folder on my HDD (sda2, ext3 format). A earlier version had a folder in the initrd as being the changes folder.
Instead of switch root'ing it just uses chroot of that aufs merged q_top folder, so you can exit back out to the initrd level again.
A pre-cursor proof of concept for the idea of the initrd potentially wget'ing both the q.sfs and a sfs copy of the q_changes folder (save folder content) from a remote site, extract the changes sfs to a folder in the initrd and then aufs mount that with the q.sfs, i.e. set things up before chroot'ing into that. And then afterwards (when exit chroot), run mksquashfs of the initrd copy of the changes back to a remote site.
That could be a very small initrd, maybe a USB stick, that doesn't even touch the PC's HDD's but uses the ethernet and PC's CPU/ram to download both the main sfs and changes sfs, runs everything in memory and preserves changes back to the remote site (no need to re-upload the main q.sfs as that is static).
With more modern systems having more than enough ram to run puppy like OS's totally in ram, storing changes in ram alongside having q.sfs also in ram is increasingly becoming less of a issue as time passes. And slower usb read/write speeds/limitations are largely replaced by ethernet/internet download speeds/limitations.
Code: Select all
#!/bin/sh
#
# Rufwoof April 2018
#
# Very crude (no error checking etc.) messing around with initrd
# and aufs layering
#
# Notes :
#
# The q.sfs in the initrd could be a filesystem just sufficient enough
# to open up a network connection and wget or similiar to retreive
# files (a proper main q.sfs and q_changes.sfs) that we can then
# setup and chroot into. Could be a simple cli type 'system' so a
# script could automate the connection/download.
export OUTPUT_CHARSET=UTF-8
mount -t proc none /proc
mount -t sysfs none /sys
mount -t rootfs -o remount,rw rootfs /
ln -s /proc/mounts /etc/mtab 2> /dev/null
export PATH="/bin:/sbin"
# Mount q.sfs (that we have stored in initrd) to q_sfs
# Mount rw (record of changes) as q_changes
# q_top is the user view layer i.e. overlaid q.sfs and changes
mkdir q_sfs q_top q_changes
mount -t squashfs -o loop,noatime /q.sfs q_sfs
mount -t aufs -o br=/q_changes=rw:/q_sfs=ro aufs /q_top
# chroot into the q_top i.e. q.sfs overlaid with sda2:/q_changes
# in combination visible as q_top
chroot /q_top /bin/sh
# so we can net connect and retreive a changes sfs file from a
# remote location
#
# CURRENTLY NOT CODED NEEDS TO BE MANUALLY RUN TO
# DOWNLOAD AND COPY THE q_changes.sfs FILE TO THE /
# FOLDER LEVEL OF q_top BEFORE EXITING THE CHROOT
# as proof of concept I ran /etc/rc.d/rc_sysinit when in the
# session, which was enough to be able to run
# busybox wget wttr.in ... that retreived a index.html file
# back to initrd level shell
/bin/busybox sh
# where we might unmount the union ... extract the changes.sfs
# file to a folder and remount again with that folder content bofore
# chrooting back to that amended q_top that includes changes
# current q_changes should have been populated with the content
#of a sfs downloaded of changes
unsquashfs /q_changes/q_changes.sfs -d q_changes_actual
# Release the current arrangement
sync
umount /q_top
umount /q_sfs
# can drop the temp q_changes content
rm -rf q_changes
# and move in the actual changes
mv q_changes_actual q_changes
# before reforming the aufs
mount -t squashfs -o loop,noatime /q.sfs q_sfs
mount -t aufs -o br=/q_changes=rw:/q_sfs=ro aufs /q_top
# and chroot into that
chroot /q_top /bin/sh
# when exit the session, sfs the q_changes folder content
# and transfer that to a remote site
# MANUAL AT PRESENT ... NOT CODED YET
# When exits from the session
# put into a repeated cli loop so can't exit to nowhere
# and reboot using ctrl-alt-delete. Or even re-enter the q_top
# level again using a command of
# chroot /q_top /bin/sh
while [ 1 -lt 8 ];do
/bin/busybox sh
done
# No traps, so if does break out of the while loop ... tidy up
sync
umount /q_top
umount /q_sfs
###################################