about summary refs log tree commit diff
path: root/nixos/doc/manual/configuration/overlayfs.section.md
blob: 592fb7c2e6f79decb1a2112e6947d1f313778bdd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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.