depot/third_party/nixpkgs/nixos/doc/manual/configuration/overlayfs.section.md
Default email 587713944a Project import generated by Copybara.
GitOrigin-RevId: 6143fc5eeb9c4f00163267708e26191d1e918932
2024-04-21 17:54:59 +02:00

734 B

Overlayfs

NixOS offers a convenient abstraction to create both read-only as well writable overlays.

{
  fileSystems = {
    "/writable-overlay" = {
      overlay = {
        lowerdir = [ writableOverlayLowerdir ];
        upperdir = "/.rw-writable-overlay/upper";
        workdir = "/.rw-writable-overlay/work";
      };
      # Mount the writable overlay in the initrd.
      neededForBoot = true;
    };
    "/readonly-overlay".overlay.lowerdir = [
      writableOverlayLowerdir
      writableOverlayLowerdir2
    ];
  };
}

If upperdir and workdir are not null, they will be created before the overlay is mounted.

To mount an overlay as read-only, you need to provide at least two lowerdirs.