[Unionfs] How to synchronized some filesystems merged with unionfs
Sylvain Ferrand
sylvain.ferrand at polytechnique.edu
Thu Nov 29 08:53:33 EST 2007
Hi,
Right, I'm merging a read-only branch (in a compact flash disk) and a rw
branch in a tmpfs. Periodically I want to remount in read-write mode the
compact flash branch to synchronize back the changes made on the tmpfs.
Then I used rsync to copy files from 'raw' tmpfs branch to CF branch.
I also use "mount -o remount,incgen ..." to flush caches after the
copy. It works pretty well even if the unionfs manpage (4) indicate this
warning " Modifying a Unionfs branch directly, while the union is
mounted is currently unsupported. Any such change can cause Unionfs to
oops, however it could even RESULT IN DATA LOSS".
Now I have a new problem, even after performing rsync, the content of
the tmpfs is not deleted and then continue to grow. Therefor I would
like to flush the tmpfs branch after a rsync. A simple 'rm' on the tmpfs
branch make the union inconsistent, at that time some deleted files
completely disappeared from the union (even if they are in the other
branch). A remount with "incgen" does not change anything.
Do you have an idea?
Thanks by advance.
Sylvain
Erez Zadok a écrit :
> In message <47137867.3060804 at polytechnique.edu>, Sylvain Ferrand writes:
>> Hi,
>>
>> I'm designing an embedded system with a read-only root(/) file
>> system (a compact flash) combined to a writable tmpfs branch.
>> It works very well, but from time to time, I would like to be able to
>> sync the tmpfs branch with the compact flash partition (to save changes
>> made to the system).
>> Do you have simples procedures to do that? I'm thinking about to create
>> a special partition and to copy the content of the tmpfs branch on it
>> and later to synchronize during the reboot.
>> I'm interested about any ideas or links to articles to do that.
>> Thanks,
>>
>> Sylvain
>
> Sylvain,
>
> I assume what you mean is that you copyup to the tmpfs branch. So what you
> want to do is sync changes that were made to the tmpfs branch, back to the
> original compact flash branch, right? Well, presumably both of these
> branches exist somewhere you can access them, and have unique namespaces. I
> assume you may have done something like this:
>
> 1. mount the root in /n/root
> 2. mount the tmpfs in /n/tmpfs
> 3. mount unionfs with dirs=/n/tmpfs:/n/root=ro on /mnt/unionfs
> 4. pivot_root onto /mnt/unionfs
>
> Most people set things up so that even after the pivot_root, you can still
> access the "raw" branches in /n/root and /n/tmpfs. So if you want to sync
> them up, you can use any tool to copy changes from /n/tmpfs to /n/root.
>
> My personal favorite is rsync because it's efficient and incremental.
> However, rsync can consume a lot of memory initially when it generates a
> recursive list of all files and dirs on the client and server, to compare
> them for changes. So if your system is short on memory, and has a lot of
> files to consider syncing, then you want to consider something that works
> directory-by-directory (I use rdist, but it hasn't been maintained very well
> in recent years). I'm sure there are other tools that can help, including a
> simple "cp -au".
>
> Once you copy files over from /n/tmpfs back onto /n/root, unionfs will
> detect those changes in [acm]time and will properly flush its caches if and
> as needed. But if you want to be safe, then your tool/script which does the
> rsync, should also issue a "mount -o remount,incgen /mnt/unionfs": this
> 'incgen' option will tell unionfs to force a flush.
>
> Cheers,
> Erez.
More information about the unionfs
mailing list