OverlayFS has a workdir option, beside two other directories lowerdir and upperdir, which needs to be an empty directory.

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. This give me the clue that it has to do with writing the merged files.

Please explain what's happening in the workdir when files are written or changed in the merged directory. Why is the writable upperdir not enough?

  • 2
    My guess: When a lower file is to be modified, it is copied (a non-atomic operation) to workdir and then atomically moved into the right place in upper. Thus, other processes will either open the (complete) lower file or (after the switch) the complete upper file, never a halfway-done file. Mar 8 '20 at 14:33

The workdir option is required, and used to prepare files before they are switched to the overlay destination in an atomic action (the workdir needs to be on the same filesystem as the upperdir).

Source: http://windsock.io/the-overlay-filesystem/

I would hazard a guess that "the overlay destination" means upperdir.

So... certain files (maybe "whiteout" files?) are non-atomically created and configured in workdir and then atomically moved into upperdir.


Because when you delete a file which is on lowerdir, this information will be stored in the workdir.

  • 1
    Hm, but when I delete files in the merged directory, the workdir remains empty but there are files shown in the upperdir with a c flag (c--------- 1 root root 0, 0 Nov 19 18:22 ivebeendeleted) when they've been "overlay-deleted" from the lower dir. (The same file remains in the lowerdir of course.) Nov 19 '16 at 17:55
  • 1
    I think when you delete a file, a "whiteout" file is created and this is stored in the upperdir, not the workdir. The whiteout file is a character device (with "c" flag)
    – ejm
    Sep 23 '17 at 8:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.