In my opinion, you should still use an initramfs. Pretty much any will do, but you'll need the squashfs file-system kernel module (if its not already compiled into your kernel) in your initramfs image.
Most initramfs systems respect fstab - and definitely Dracut does. And so you can just configure two /etc/fstab
files - one in your .sfs
image and one in your initramfs image.
{ cd /tmp; cat >fstab
mkdir -p sfs/sfs sfs/usb
dracut -i fstab /etc/fstab \
-i sfs sfs \
--add-drivers overlay \
--add-drivers squashfs \
initramfs.img
} <<"" #FSTAB
UUID={USB-UUID} /sfs/usb $usbfs defaults 0 0
/sfs/usb/img.sfs /sfs/sfs squashfs defaults 0 0
In all honesty I'm not perfectly familiar with the dracut
initramfs build system, and so there may be something more necessary for that command to complete successfully. I'm working with a general familiarity of how most initramfs mounts are set up and the information I find in the man
page for dracut
here. Some further assembly may be necessary, but this should bring you along fairly well.
After you've installed a proper /etc/fstab
to your initramfs, you should then be able to use the following root device related parameters to get an overlayfs rootfs:
root=overlay \
rootfstype=overlay \
rootflags=\
lowerdir=/sfs/sfs,\
upperdir=/sfs/usb/persist,\
workdir=/sfs/usb/tmp
This assumes you have a directory on your usb drive named /persist
and another empty one named /tmp
and that your squashfs image can be found at the root of your usb filesystem as /img.sfs
.