diff options
| author | tv <tv@krebsco.de> | 2026-11-23 03:09:47 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-23 03:09:47 +0000 |
| commit | 80ba3bf268599935af96318c9eb051245640986c (patch) | |
| tree | 84a01169919149267fbc08b85ca14eed8e5894f5 /pkgs/run-firecracker-vm/default.nix | |
| parent | 86561dbdd2a91b1d0bc5e3f9fa1fab5331ccd3ec (diff) | |
run-firecracker-vm: the store's layers as lowerdir+=, not one lowerdir
NixOS's overlay.lowerdir makes the store's lower layers a single mount
option, lowerdir=/sysroot/nix/.image/0:..., which util-linux passes with
the new mount API, which caps a string option at 255 bytes: at most 11
images, 10 with nix. Now the base system generates the store's mount
from the layers, a lowerdir+= each (kernel 6.8 and later), which has
that limit per path only (tested in a user namespace: 30 long paths,
4470 bytes, mount; a single lowerdir of them doesn't; and lowerdir+=
can't follow lowerdir=, so it's one or the other). The limit is now
Firecracker's number of devices.
The lower layers are fc.storeLowerdirs: the images first, as reading
them is fast, then what layers add, like layers/nix.nix the host's
store, which also adds its upper layer to the options, created by
fc-rw-store-unshadow now (NixOS's service for that comes only with
overlay.lowerdir).
Diffstat (limited to 'pkgs/run-firecracker-vm/default.nix')
| -rw-r--r-- | pkgs/run-firecracker-vm/default.nix | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/pkgs/run-firecracker-vm/default.nix b/pkgs/run-firecracker-vm/default.nix index 63cb06a..5f07e0c 100644 --- a/pkgs/run-firecracker-vm/default.nix +++ b/pkgs/run-firecracker-vm/default.nix @@ -130,6 +130,13 @@ let internal = true; description = "Whether the guest has layers/nix.nix."; }; + # The store's lower layers: the images (from the layers), and + # what layers add, like layers/nix.nix the host's store. + options.fc.storeLowerdirs = lib.mkOption { + type = lib.types.listOf lib.types.str; + internal = true; + description = "The store's lower layers, as in the guest's /."; + }; options.fc.mountVsock9p = lib.mkOption { type = lib.types.package; default = mountVsock9p; @@ -196,10 +203,17 @@ let # imageFileSystems and images below), read-only, or with # layers/nix.nix, writable. Without an upper layer, overlayfs needs # at least two lower ones: a single image is the store itself - # (mounted a second time). + # (mounted a second time). Not with overlay.lowerdir: NixOS makes + # that a single option (lowerdir=A:B:...), which the mount API caps + # at 255 bytes, i.e. about 10 images; a lowerdir+= each has no such + # limit. An upper layer (layers/nix.nix) adds its own options. + fc.storeLowerdirs = lib.mkBefore lowerdirs; # images first: 9P is slow fileSystems."/nix/store" = - if lib.length lowerdirs > 1 then { - overlay.lowerdir = lowerdirs; + if lib.length config.fc.storeLowerdirs > 1 then { + fsType = "overlay"; + device = "overlay"; + depends = config.fc.storeLowerdirs; + options = map (d: "lowerdir+=/sysroot${d}") config.fc.storeLowerdirs; } else (imageFileSystems 1)."/nix/.image/0"; |
