Page 1 of 1

saveoverlays sometimes fails to sync when rebooting Raspbian Stretch

Posted: Saturday 14 October 2017 8:00
by ayoko309
Hello.

I have a question about saveoverlayfs which is explained here. https://www.domoticz.com/wiki/Setting_u ... spberry_Pi

I'm running 2017-09-07-raspbian-stretch-lite.img on Raspberry Pi 3, and followed the explanation on the above page.
(So far, I was using your technique with Raspbian Wheezy and working fine. However I'm confused because I'm not familiar with systemd in Jessie and Stretch.)

After set-up of the saveoverlayfs, it looks working mostly, but I found a severe problem. The phenomenon is, while repeating log-in for the account 'pi' and "sudo shutdown -r now", sometime the directory /home gets lost. After debugging the script /etc/init.d/saveoverlayfs, I found its reason.

In the loop below, even the directory (or mount point) "/home" actually exists in the variable OVERLAYFS,

for DIR in ${OVERLAYFS}
do
...

when the command rsync tries to copy the file in the /home, the directory /home looks already unmounted at the time by some reason.
Because /home is unmounted, rsync considers that the directory is empty and /home_stage also becomes empty, and the contents of /home_org gets lost. (rsync removes the contents of the directory as shown below.)

saveoverlays sync /home to /home_org with options -avH --delete-after --inplace
--no-whole-file --exclude *.leases at Sat 14 Oct 04:53:23 UTC 2017
---- Staging to /home_stage ------
building file list ... done
./
deleting pi/.wget-hsts
deleting pi/.profile
deleting pi/.bashrc
deleting pi/.bash_logout
deleting pi/.bash_history
deleting pi/

sent 43 bytes received 18 bytes 122.00 bytes/sec
total size is 0 speedup is 0.00
---- Copy to /home_org ------
building file list ... done
./
deleting pi/.wget-hsts
deleting pi/.profile
deleting pi/.bashrc
deleting pi/.bash_logout
deleting pi/.bash_history
deleting pi/

sent 43 bytes received 18 bytes 122.00 bytes/sec
total size is 0 speedup is 0.00
saveoverlays sync /home to /home_org ended at Sat 14 Oct 04:53:23 UTC 2017


I checked the beginning part of the script, and I found the following declaration.

# Required-Stop: umountfs

I guess, it means that unmount of /home needs to come after the saveoverlayfs. However, when rsync is trying to sync files, there looks a chance that the directory /home was already unmounted.

I don't know why this occur because I'm afraid that I'm not familiar with systemd behavior.

Any suggestion would be highly appreciated.

Regards,
Atsushi