[Unionfs] How to synchronized some filesystems merged with unionfs

Sylvain Ferrand sylvain.ferrand at polytechnique.edu
Thu Dec 13 09:30:44 EST 2007


Hello,

Thanks for your help, but I still have some difficulties.
I have an union like that:
unionfs on / type unionfs 
(rw,dirs=/old/tmpfs_layer=rw:/old/rw_layer=ro:/old=ro)
Where
- /old/tmpfs_layer is a tmpfs read-write branch
- /old/rw_layer a is branch on a compact flash used to flush changes 
from tmpfs_layer
- /old/ is a ro branch on a compact flash

I have no problem to copy data from /old/tmpfs_layer to /old/rw_layer, 
it works very well with unionfs 2.1. But I still have some difficulties 
to cleanly deletes files from the tmpfs branch.
I understand I have to remove the tmpsfs branch from the union before to 
delete files. Unfortunately I cannot do that!
In my case the union is for the root directory, then I cannot remount 
the union in read-only mode (mount -t unionfs -o remount,ro / -> device 
is busy).
Then I tried to insert a new tmpfs read-write branch at the highest 
priority, and to downgrade the old tmpfs branch to read-only mode and 
then to remove the old tmpfs branch from the union
Here is the detail:
# mount | grep unionfs
unionfs on / type unionfs 
(rw,dirs=/old/tmpfs_layer=rw:/old/rw_layer=ro:/old=ro)
#mount -t tmpfs tmpfs /old/tmpfs_layer2/
#mount -t unionfs -o 
remount,add=/old/tmpfs_layer2/,mode=/old/tmpfs_layer/=ro none /
# mount | grep unionfs unionfs on / type unionfs 
(rw,dirs=/old/tmpfs_layer2=rw:/old/tmpfs_layer=ro:/old/rw_layer=ro:/old=ro)
# mount -t unionfs -o remount,del=/old/tmpfs_layer/ none /
mount: / is busy

Even with a new rw branch at the highest priority, I cannot remove the 
old tmpfs branch, I always get the message "/ is busy"
Do you think I can do that when the union is on the / directory?
Thanks by advance,

Sylvain

Erez Zadok a écrit :
>> 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.
> 
> OK, so if I understood you, after you resync from the tmpfs back to the
> flash, you want to delete all files from the tmpfs and then start again.  In
> that case, it would be best to first remove the tmpfs branch from your
> union, then rm -rf it, and then add it back to your union.  So the rough
> order of events will be something like that (I didn't try it yet):
> 
> - assume /tmpfs is your tmpfs partition and /flash is your writeable flash
> - mount -t unionfs -o dirs=/tmpfs:/flash none /union
> - you make whatever changes through the union
> - then you follow the procedure we already discussed to flush changes from
>   /tmpfs to /flash
> - mount -t unionfs -o remount,ro /union
> 	# the above is probably needed before you can
> 	# remove /tmpfs from the union, IF /flash is
> 	# mounted readonly
> - mount -t unionfs -o remount,del=/tmpfs none /union
> - rm -rf /tmpfs/*
> - mount -t unionfs -o remount,add=/tmpfs none /union
> - mount -t unionfs -o remount,rw none /union
> 
>> Sylvain
> 
> Erez.



More information about the unionfs mailing list