Home Explore Blog CI



nixpkgs

nixos/doc/manual/configuration/overlayfs.section.md
7f4de50562a42aad2e9077270e613bdd829dab1df59fbec000000003000002de
# Overlayfs {#sec-overlayfs}

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

```nix
{
  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 `lowerdir`s.

Chunks
79728b82 (1st chunk of `nixos/doc/manual/configuration/overlayfs.section.md`)
Title: Overlayfs in NixOS
Summary
NixOS provides an abstraction for creating read-only and writable overlays using Overlayfs. The configuration involves specifying the `lowerdir`, `upperdir`, and `workdir` options. If `upperdir` and `workdir` are provided, they are automatically created before mounting the overlay. To mount an overlay as read-only, at least two `lowerdir` directories must be specified.