rockedge wrote: ↑Tue Feb 01, 2022 2:35 pm
@wiak can you show an example of the rsync script line?
I can @rockedge, but with the disclaimer that I am not saying this line is 'correct'. For one thing, I am unnecessarily syncing caches with this line. Also, the issue is whether overlayfs whiteout files are an issue - remember:
https://www.kernel.org/doc/html/latest/ ... layfs.html
"A whiteout is created as a character device with 0/0 device number"
I haven't really considered the implications of all of this. I know, when @fredx181 later created his first overlayfs DebianDog (BusterDog?) he ended up writing a relatively complex rsync-based script to search for and deal with whiteouts in the way he felt likely necessary. I, however, have always used a very simple one-liner, and used it for months with no issues, but I may just have been lucky... This is for w_changes=RAM2 mode only, which is where external media upper_changes gets mounted to /mnt/layers/uc_ro, which is used as top read-only layer by mount overlay, and the session (read/write) upper_changes gets put in /mnt/layers/RAM/upper_changes.
Here is the simply rsync line I use to merge session upper_changes with external media upper_changes for that RAM2 mode:
Code: Select all
sudo rsync -av /mnt/layers/RAM/upper_changes/ /mnt/sda4/WDL_whatever/upper_changes
Now, I admit to simply using that (and successfully in terms of nothing (apparently) bad happened (?) when I used it and it seemed to work) but did not investigate its effects (re: whiteouts) carefully. I was too busy to check all that all and never got round to it. Worth a big discussion, testing, and evidence regarding issues that might occur though. I did use it for months though (and am about to use same method again). I am planning to also examine the likely whiteout-related possible issues more carefully though; I haven't published the line before because I know it could be insufficient and don't want anyone complaining I wrecked their install!!! So, yes, totally at your own risk and not for production system thus far. Fred's bigger rsync script used in overlayfs DebianDogs has been used by others for quite a while now. Even if my one-liner proves not to be 'dangerous' or 'insufficient' depending on deletions to files and so on, it certainly needs improved anyway to include not rsyncing back unnecessary caches and so on.
One thing related I'm about to look into is that the copy command 'cp' does not, by default at least, copy 0,0 char device files (not even cp -a; EDIT: I'm wrong. It does... see foot of post EDIT).
One other thing is the ever useful old tape archive" utility 'tar', as far as I know, does indeed faithfully archive everything so that may prove to be useful in accurate remasters or filesystem merges too, which is worth keeping in mind I feel. Yes, I must look into this save-back mechanism, merges, and remastering sometime - I really have a feeling that tar may prove useful if all else fails or introduced problems, but DebianDogs already done a lot of this kind of work and no major issues there apparently.
Overall it is important to really work out the effect whiteout files are having between all the different filesystem layers - it would be wrong to delete whiteout files in intermediate layers, it seems to me, without finding out what they refer to and which layer (filesystem) the object resides in actually deleting that. Such would involve big overall layer search and delete operation; I took the view that I may not need to deal with intermediate layer whiteouts so just leaving them in since they will continue to fulfill their designed purpose of hiding underlying files - different matter remastering of course since want to cut down the saved result, but I take the view that /mnt/layers/merged effectively contains what I'd want as a remaster anyway (minus unneeded caches and similar) - that won't contain any whiteouts because merged is the final result of the mount overlay command.
I should add, that for our business machine install, I never use rsync back anything. Rather I run these machines in w_changes=RAM2 mode for normal use and don't rsync back anything (i.e. I keep them pristine between boots). If I really do want to modify these systems (e.g. new configs or new apps) I simply temporarily run them as w_changes="" mode (which is same as not using w_changes line on the grub kernel at all, such that any changes go immediately into external media upper_changes so will be there on next boot too. Then I change the grub kernel line back to w_changes=RAM2 mode prior to next boot and don't save further sessions back - i.e. I play safe... and don't rsync anything on the business-use install (I simply don't trust any rsync mechanism/algorithm/script totally (!!!) so either just save persistence back everything immediately (rather than holding session changes temporarily in RAM) or run in no-save-persistent mode).
EDIT: just checked rsync man pages and it has the following related to above options:
--devices
This option causes rsync to transfer character and block device files to the remote system to recreate these devices. This option has no effect if the receiving rsync is not run as the super-user (see also the --super and --fake-super options).
--specials
This option causes rsync to transfer special files such as named sockets and fifos.
I don't know if the above are included in rsync defaults or not (would have to experiment). I checked man page for cp command but can't see any similar options for that, so worth bearing in mind. But, as I say, tar should be fine (I think...) since it makes proper archive usually.
EDIT2: Just did a simple experiment to check my above rsync line operation with whiteout file included (not a direct RAM2 rsync experiment, just a simple direct to other folder rsync experiment). What I did is made a new empty directory: /mnt/sda4/WDL_arch64/test
and then, I deleted, the vmlinuz I had in my main WDL_ARCH64 rootfilesystem in /boot. That could then be seen as a vmlinuz 0,0 char whiteout file in /mnt/layers/RAM/upper_changes/boot (I'm running under w_changes=RAM2 mode, hence session changes are instantly reflected into /mnt/layers/RAM/upper_changes). Then I simply tried rsyncing that directory back to the empty 'test' directory by using command:
Code: Select all
sudo rsync -av /mnt/layers/RAM/upper_changes/ /mnt/sda4/WDL_arch64/test
That copied down all of /mnt/layers/RAM/upper_changes into that 'test' directory. I checked /mnt/sda4/WDL_arch64/test/boot/ and sure enough the vmlinuz 00 char whiteout file was correctly there. I continue to believe that is sufficient - that I don't really need to worry about any other whiteout files in lower down layer filesystems (they will continue to do their correct overlay job...). I could be wrong, but seems to me to be as simple as that (except I don't also want to rsync back all these caches, but that just needs me to add some of these valid additional rsync options to (either or both):
Code: Select all
--exclude=PATTERN exclude files matching PATTERN
--exclude-from=FILE read exclude patterns from FILE
Actually, the above simple 'test' experiment indicates an alternative method of 'saving a session'. In above, I didn't rsync back to media upper_changes, so if I now rebooted the session (deleted boot/vmlinuz in this experiment case) would be lost, so boot/vmlinuz would be back again... However, I 'could' add another mode (RAM3, not there at the moment) to the WDL initrd/init (or simply the extra code in external w_init (so just optional then) that would boot into RAM2 mode but additionally rsync 'test' (or whatever it is named) back into empty boot version of /mnt/layers/RAM/upper_changes. Then when mount overlay done, that previous 'test' session would already be re-loaded...
I don't intend implementing that RAM3 alternative session save into the main initrd/init, but worth doing as optional plugin w_init form I think (since very simple and safe save persistence mechanism - disadvantage being that it uses more RAM since whole last session copied back into RAM rather than ending in loop mounted external upper_changes).
I consider w_changes=RAM2 mode the most useful though and most RAM efficient, so top of post given rsync line is for that (albeit with the disclaimers...).
All illustrates the power of w_ optional plugins... not fixed and simplified boot options, with the limits these bring, but instead flexible boot options are the result - that's why initrd/init in simple shell-script form with optional external w_init file is so useful in terms of easy plugin/editing/flexibility (and since busybox in initrd, awk language is also available for w_init plugin use).
Thanks for asking about this rockedge, because thinking about it all makes me realise an error I have in current RAM1 mode (RAM2 mode is fine). In w_changes=RAM1 mode I use cp -a to copy external upper_changes up into /mnt/layers/RAM/upper_changes when I really should use rsync since cp is not including any whiteout files...
I will fix that RAM1 mode in next WDL initrd release, but probably no-one using memory-inefficient RAM1 mode anyway - I'm not either since only using no w_changes (same as w_changes="") or using w_changes=RAM2 mode. EDIT: I am wrong. Just tried cp -a and that also did indeed copy the whiteout file so existing w_changes=RAM1 mode should be okay and not need fixed. Overall, rsync is a nicer way to do most copying though since doesn't repeat copy what is already there...