User override of top-level zram
I have recently posted about top-level zram in the aufs layered
filesystem. See posts linked from here:
https://bkhome.org/news/202205/containers-now-have-top-level-zram.html
This means that as you use the applications, download packages, etc., it will all be happening in zram, with no writes to the drive. Instead, there is a "save" icon on the desktop, and save is offered at shutdown, when or if you want to save the work to the drive.
This is great for a flash drive, where you likely want to limit writes to the drive; however, if Easy is installed to a HDD or a high-quality SSD, it will not be such a concern. In that case, you might prefer the previous behaviour with direct writes to the drive, and no "save" icon on the desktop.
I know that some people prefer to have a "save" icon anyway, as a security measure. That is, if something happens that you don't like, just shutdown without saving.
Anyway, there is now a mechanism for users to override the default setting for top-level-zram...
The choice is made in woofQ, in file 'build-choices', which has "EOS_TOP_LEVEL_ZRAM=1" or anything else including undefined meaning disabled. The '3buildeasydistro' script in woofQ inserts this variable into the 'init' script in the initrd, and that inserts it into /etc/rc.d/PUPSTATE so that the running system can read whether there is a top-level-zram or not.
I have added the ability for override in the kernel boot parameters. Easy allows "qfix=" followed by various options, such as "qfix=nox" meaning to bootup to the commandline only, no X. The options can be comma-delimited, so "qfix=nox,fsck" will also do a filesystem check.
I have added another option; "qfix=zramtl0" or "qfix=zramtl1" meaning to disable or enable top-level-zram respectively.
I have also implemented another way to override, by a file in the boot-partition. File ${BOOT_DIR}.zramtl.flg in the boot-partition may have "1" or "0" in it. The 'init' script will read that and override EOS_TOP_LEVEL_ZRAM. For now, you would have to manually create that file, but could later put it into a GUI somewhere.
For a bit more technical description, the 'init' script has this:
EOS_TOP_LEVEL_ZRAM=1 #20220521 1=yes, anything else no.
...
ZRAMTL='' #20220603 override EOS_TOP_LEVEL_ZRAM
[ "$qfix" ] && QFIX=$qfix #kernel boot param
if [ "$QFIX" ];then
for ONEFIX in `echo -n "$QFIX" | tr ',' ' '`
do
case $ONEFIX in
lock*|LOCK*) LOCKDOWN="${ONEFIX:4:1}" ;; #200803 extract the number.
dropout*|DROPOUT*) DROPOUT="${ONEFIX:7:1}" ;; #200801 extract the number
normal|NORMAL) NORMAL=1 ;; #200809 to remove permanent lockdown.
vid|VID) BROKENVID=1 ;; #20211014
zramtl*|ZRAMTL*) ZRAMTL=${ONEFIX:6:1} #20220603 zramtl0 disable, zramtl1 enable.
esac
done
fi
...
if [ "$ZRAMTL" ];then #20220603
EOS_TOP_LEVEL_ZRAM=${ZRAMTL} #override.
fi
...
if [ "$ZRAMTL" == "" ];then #20220603 that is, not a kernel param.
if [ -s /mnt/${BOOT_DEV}/${BOOT_DIR}.zramtl.flg ];then
EOS_TOP_LEVEL_ZRAM=$(cat /mnt/${BOOT_DEV}/${BOOT_DIR}.zramtl.flg) #1 or 0
fi
...
if [ "$LOCKDOWN" ];then
#disable the extra zram1 top layer...
EOS_TOP_LEVEL_ZRAM=0
fi
...
if [ $EOS_TOP_LEVEL_ZRAM -eq 1 ];then #20220527
mount -t ${WKG_FS} -o commit=30,rw,noatime,data=ordered /dev/${WKG_DEV} /mnt/${WKG_DEV} 2>/dev/null
else
mount -t ${WKG_FS} -o commit=30,rw,relatime,data=ordered /dev/${WKG_DEV} /mnt/${WKG_DEV} 2>/dev/null
fi
RET=$? #200715 it was going to err_exit, need this $RET...
if [ $RET -ne 0 ];then
if [ $EOS_TOP_LEVEL_ZRAM -eq 1 ];then #20220527
mount -t ${WKG_FS} -o noatime /dev/${WKG_DEV} /mnt/${WKG_DEV} #200624 fallback if no journal
else
mount -t ${WKG_FS} /dev/${WKG_DEV} /mnt/${WKG_DEV} #200624 fallback if no journal
fi
RET=$?
fi
...
if [ $EOS_TOP_LEVEL_ZRAM -eq 1 ];then #20220521
create_top_level_zram1
mount -t ext2 /dev/zram1 /easy_rw
mkdir /easy_rw/mainrw #20220529 mainrw will be the aufs top-level layer.
if [ "$EOS_SUPPORT_CONTAINERS" != "0" ];then #20220529
#these will be the rw layer for containers...
mkdir /easy_rw/www
mkdir /easy_rw/console
mkdir /easy_rw/ssh0
mkdir /easy_rw/${INIT_DISTRO_COMPAT_VERSION} #ex: dunfell, bookworm
fi
fi
...
if [ $EOS_TOP_LEVEL_ZRAM -eq 1 ];then #20220521 20220529
mount -t aufs -o br=/easy_rw/mainrw=rw:${SESSIONHOME}=ro+wh:${sessionSFS}${EXTRASFS}/easy_ro/easy_sfs=ro aufs /easy_new
else
mount -t aufs -o br=${SESSIONHOME}=rw:${sessionSFS}${EXTRASFS}/easy_ro/easy_sfs=ro aufs /easy_new
fi
...
echo "EOS_TOP_LEVEL_ZRAM='${EOS_TOP_LEVEL_ZRAM}'" >> /easy_new/etc/rc.d/PUPSTATE #20220521
...the above code snippets are showing all the places in the 'init' script where EOS_TOP_LEVEL_ZRAM is being referenced.
In the case of LOCKDOWN being set, that runs totally in zram with
drives unmounted and even disabled, that mode copies the entire
session folder into RAM. It is an entirely different mechanism,
with its own special "save" icon on the desktop, and will unset
EOS_TOP_LEVEL_ZRAM.
Tags: easy