Ubuntu – Overlayfs reload with multiple layers (migration away from aufs)

12.04filesystemmountunionfs

I've come across one of those aufs to overlayfs migration headaches. With aufs you could specify multiple RO-layers and updating some files in them was refreshed with remount.

fstab with aufs:

aufs    /etc                       aufs    noauto,br:/rw-root/etc=rw:/ro-root/etc=ro:/etc=rr  0 0

Same functionality with overlayfs:

none    /.tmp-root/etc              overlayfs  noauto,upperdir=/ro-root/etc,lowerdir=/etc      0 0 
none    /etc                       overlayfs  noauto,upperdir=/rw-root/etc,lowerdir=/.tmp-root/etc  0 0 

Mounting the system in order is fine and everything works. The problem arises when I need to update something on the ro-root partition. Running remount on that sees /etc as the already mounted overlayfs and not the original ro-root. (Solved the striked-out problem with mount --bind)

Apparently the problem is with inode numbers of the files. So editing of a file works fine, but if I copy a new file over the old one on the lower level, the change is not propagated. So this could be a real overlayfs problem.

I'd really like this setup to continue working (restructuring everything is quite a lot of work and testing that I'd rather avoid, because this affects +50 virtualmachines).
That being said, I will also accept answers that would accomplish moving readonly-root after initrd-stage safely to go around this problem and if that's not possible then suggestion most minimalistic way of changing/modifying/creating initrd to accomplish this move.

There's another related question, but it's the simpler form of just two layers.
Simple overlayfs reload question

Best Answer

have you tried running remount on /.tmp-reoot/etc first and then remount on /etc

e.g.:

 mount -o remount /.tmp-reoot/etc

 mount -o remount /etc