Table of Contents
Overlay Filesystem Basic
Overlay filesystem merges lower and upper directories into merged directory.
Mount writable
mount -t overlay overlay -o lowerdir=/lower1:/lower2:/lower3,upperdir=/upper,workdir=/work /merged
The above example will have the order:
/upper
/lower1
/lower2
/lower3
- The lower directory can be read-only or could be an overlay itself.
- The upper directory is normally writable.
- The work directory is used to prepare files as they are switched between the layers, it needs to be an empty directory on the same filesystem mount as the upper directory.
- All changes in the merged directory are still reflected in upper.
- New files created in lower and upper will be shown in merged.
- All files before opened directory, the content is still mapped according to layer.
- All files after opened in merged directory, the content will not be reflected in merged directory.
Mount read-only
To mount as read only, no upper and work directory are required.
mount -t overlay overlay -o lowerdir=/lower1:/lower2 /merged
Whiteout files
Whiteout is to simulate a file removed from upper layer directory. It is created as a character device with 0/0 device number.
Opaque directories
Opaque is to simulate a directory removed from upper layer directory. It is made by setting the xattr “trusted.overlay.opaque” to “y”.
References
Overlay filesystem
Overlay Filesystem
Explaining OverlayFS – What it Does and How it Works