<div dir="ltr">Looking for a sanity check from the folk how know more of systemd than do I. Not looking for someone else to solve my problem, but could use a clue. <div><br></div><div>Trying to figure out how to get an overlayfs root mounted early in boot.</div><div><br></div><div>Building an embedded system that must not store any sensitive data when powered down. Found this was referred to on this list more recently as a "stateless" system. (And Tobias Hunger seems to have the most to say. :) ) We are using Centos8, with systemd 239. Starting point is a vanilla Centos8 server installation to a small (8 or 32GB) flash volume.<div><br></div><div>Had the (possibly) clever notion of using an overlayfs as the root mount, with a tmpfs as the upper, and the usual persistent volume as the lower. The  initial round of configuration and test would just be against a stock Centos8 install. Once fully configured and tested, would add a default boot menu item to boot with root mounted as an overlayfs, with the fully configured root volume as the read-only lower.</div><div><br></div><div>Updates would be accomplished by booting from the original boot menu entry. (This is slightly complicated by the fact the target systems' computers do not have a console - but figure I can script altering the default boot.)</div><div><br></div><div>Have what I think is a properly configured overlayfs root. Currently hung up on getting that root mounted early enough(?) in boot. Working down a list of possibilities. :)<br><br></div><div>Have a script to repeatably build/rebuild the overlayfs root. Relevant commands (w/o supporting logic):</div><div>----</div><div>BASE=/run/overlay_root</div><div>OVERLAY=$BASE/merged</div><div>ROOT_MOUNT=$OVERLAY/mnt/root</div><div>mount -t tmpfs root-base $BASE ; mkdir $BASE/{lower,upper,work,merged}</div><div>mount --bind / $BASE/lower</div><div>mount -t overlayfs root-overlay $OVERLAY -olowerdir=$BASE/lower,upperdir=$BASE/upper,workdir=$BASE/work</div><div>for d in boot dev proc run sys ; do mount --bind /$d $OVERLAY/$d ; done<br></div><div>mkdir $ROOT_MOUNT ; mount --bind / $ROOT_MOUNT</div><div>----</div><div>This all seems to work. The overlayfs prevents writes to persistent media in usual places. Have a path to write to persistent media. The special directories (that do not work from mounts to lower on an overlayfs) work as expected.</div><div><br></div><div>What I do not have as yet is a means to get the overlayfs root mounted early in boot.</div><div>1.  Does not look like /etc/fstab can create the overlayfs.</div><div>2.  Tried the "systemd.volatile=yes" kernel command line, w/o luck. Substantial commits between 239 and 245 around this.</div><div>3.  See systemd "pivot_root" and "switch_root", but not yet puzzled out usage.</div><div><br></div></div><div>Looking for where/how to swap in the overlayfs root early in boot. Or tell me I'm an idiot, and this will not work. :/</div><div><br></div></div>