Overlay session save bug
Not happy that this one got through. Whiteout-files, that are character devices in overlay, weren't getting applied to delete the underlying file at shutdown.
I posted about the pivot_root method of session save:
https://bkhome.org/news/202509/save-session-by-pivotroot-for-overlayfs.html
What I discovered is that the 'cp' utility doesn't copy character devices after the pivot_root. It just silently ignores them, no error messages.
The fix is that the copy of the overlay rw-layer has to be done before the pivot_root, to a folder somewhere, then a symlink to it after the pivot-root. The script /etc/rc.d/shutdown-pivot-root has these changes shown in bold:
[ -d /mnt/${WKG_DEV}/${WKG_DIR}.shutdown/rw1 ] && rm -rf /mnt/${WKG_DEV}/${WKG_DIR}.shutdown/rw1
[ -d /mnt/${WKG_DEV}/${WKG_DIR}.shutdown/wkg1 ] && rm -rf /mnt/${WKG_DEV}/${WKG_DIR}.shutdown/wkg1
mkdir -p /mnt/${WKG_DEV}/${WKG_DIR}.shutdown/rw1
mkdir -p /mnt/${WKG_DEV}/${WKG_DIR}.shutdown/ro1
mkdir -p /mnt/${WKG_DEV}/${WKG_DIR}.shutdown/wkg1
mkdir -p /mnt/${WKG_DEV}/${WKG_DIR}.shutdown/top1
#20250918 cp before pivot_root, so will also copy char devices (see symlink below)...
[ -d /mnt/${WKG_DEV}/${WKG_DIR}.shutdown/easy_rw ] && rm -rf /mnt/${WKG_DEV}/${WKG_DIR}.shutdown/easy_rw
cp -a /mnt/.easy_rw /mnt/${WKG_DEV}/${WKG_DIR}.shutdown/easy_rw
cd /mnt/${WKG_DEV}/${WKG_DIR}.shutdown
busybox mount -t squashfs ../sfs/easyos/${DISTRO_BINARY_COMPAT}/${DISTRO_COMPAT_VERSION}/easy_${DISTRO_VERSION}_amd64.sfs ro1
busybox mount -t overlay -o xino=on,nfs_export=off,index=off,uuid=null,verity=off,redirect_dir=off,metacopy=off,lowerdir=ro1,upperdir=rw1,workdir=wkg1 overlay top1
#busybox mount -t aufs -o udba=none,br=rw1=rw:ro1=ro aufs top1
mkdir -p top1/old_root
cd top1
busybox pivot_root . old_root
if [ ! -e /old_root/etc/DISTRO_SPECS ];then
cd /
echo -e "\\033[1;31m" >/dev/console #red
echo "ERROR: unable to pivot_root" >/dev/console
echo "Fallback to indrect save (completed at next bootup)..." >/dev/console
echo -e "\\033[0;39m" >/dev/console #restore default color.
busybox umount top1 2>/dev/null
busybox umount ro1 2>/dev/null
sleep 0.5
mkdir -p /mnt/${WKG_DEV}/${WKG_DIR}.session-transit
/etc/rc.d/rw-merge '.session-transit'
else
#busybox mount -t proc proc /proc
#20250913 in rw-merge will write direct to ro layer of old overlayfs
# this will upset it, docs say cause "undefined behaviour" but it won't crash.
# the following line works, but just in case "undefined behaviour" causes changes
# on the rw layer, copy it instead of symlink...
#busybox ln -snf /old_root/mnt/.easy_rw /mnt/.easy_rw
#20250918 doen't cp char devices, see cp above...
#busybox cp -a /old_root/mnt/.easy_rw /mnt/
busybox ln -snf /mnt/${WKG_DEV}/${WKG_DIR}.shutdown/easy_rw /mnt/.easy_rw
busybox ln -snf /old_root/mnt/.easy_ro /mnt/.easy_ro
Next release, Easy 7.0.13, coming tonight.
Tags: easy