Contents
What is the workdir used for in OverlayFS?
Unfortunately the kernel documentation of overlayfs does not talk much about the purpose of this option. The “workdir” needs to be an empty directory on the same filesystem as upperdir. For readonly overlays the workdir might be ommittet among the upperdir.
How to merge two directories in overlay filesystem?
At mount time, the two directories given as mount options “lowerdir” and “upperdir” are combined into a merged directory: mount -t overlay overlay -olowerdir=/lower,upperdir=/upper,workdir=/work /merged The “workdir” needs to be an empty directory on the same filesystem as upperdir.
How to enable Overlay Filesystem in Linux kernel?
The “xino” feature can be enabled with the “-o xino=on” overlay mount option. If all underlying filesystems support NFS file handles, the value of st_ino for overlay filesystem objects is not only unique, but also persistent over the lifetime of the filesystem.
How to Mount OverlayFS as read-write FS-Unix?
As the example shows, upperdir= and workdir= may be omitted. In that case the overlay will be read-only. The specified lower directories will be stacked beginning from the rightmost one and going left. In the above example lower1 will be the top, lower2 the middle and lower3 the bottom layer.
Can you run OverlayFS on top of a file system?
As long as you mount a volume on /var/lib/containers inside of you container then it should work. You are not allowed to run overlayfs on top of a file system that is already overlay. We’re not allowed to mount host’s paths in this K8s setup, is there any other way beyond slower solutions like VFS ?
How does an overlay filesystem support RM and rmdir?
In order to support rm and rmdir without changing the lower filesystem, an overlay filesystem needs to record in the upper filesystem that files have been removed. This is done using whiteouts and opaque directories (non-directories are always opaque). A whiteout is created as a character device with 0/0 device number.
How does OverlayFS protect the root filesystem?
Depending on the block device chosen, those changes can persist across reboots. While the root filesystem will not be affected, the view presented by OverlayFS will include any changes stored in the upper filesystem. For our embedded Linux device, we are not interested in preserving any changes to the root filesystem.
Is there a way to mount the root filesystem?
Running mount, we should see something like: Note how the root filesystem is of type overlayfs with specified upper and lower filesystems that correspond to the read-write tmpfs and read-only mounts listed. Once overlayroot is enabled, it is no longer possible to make changes to the root filesystem.
How to prevent overlayroot on read only filesystem?
This can be prevented by adding another option to the configuration: Note that swap=1 and recurse=0 are separated by a comma, not a colon. (The default value for recurse is 1). This will prevent overlayroot from overlaying a read-write tmpfs on top of a read-only /data filesystem.