From 80ba3bf268599935af96318c9eb051245640986c Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 23 Nov 2026 03:09:47 +0000 Subject: 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). --- layers/nix.nix | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'layers') diff --git a/layers/nix.nix b/layers/nix.nix index 67639be..b679539 100644 --- a/layers/nix.nix +++ b/layers/nix.nix @@ -5,7 +5,7 @@ # its images, read-only. With it, the run script requires --store. { config, lib, pkgs, ... }: let - inherit (config.fileSystems."/nix/store".overlay) lowerdir; + lowerdir = config.fc.storeLowerdirs; in { nix.enable = true; @@ -50,10 +50,11 @@ in }; # The images are an overlay already: this is one image more than the # base system, so there are at least two. - fileSystems."/nix/store".overlay = { - lowerdir = [ "/nix/.host-store" ]; - upperdir = "/nix/.rw-store/store"; - workdir = "/nix/.rw-store/work"; + fc.storeLowerdirs = [ "/nix/.host-store" ]; + # The upper layer, which fc-rw-store-unshadow (below) creates. + fileSystems."/nix/store" = { + depends = [ "/nix/.rw-store" ]; + options = [ "upperdir=/sysroot/nix/.rw-store/store" "workdir=/sysroot/nix/.rw-store/work" ]; }; # nix in the guest deletes a path in the store that isn't in its # database before it adds it, like the host's store's paths. On the @@ -70,7 +71,8 @@ in unitConfig.RequiresMountsFor = map (d: "/sysroot" + d) ([ "/nix/.rw-store" ] ++ lowerdir); serviceConfig.Type = "oneshot"; script = '' - cd /sysroot/nix/.rw-store/store 2>/dev/null || exit 0 + mkdir -p -m 0755 /sysroot/nix/.rw-store/store /sysroot/nix/.rw-store/work + cd /sysroot/nix/.rw-store/store for p in *; do for d in ${toString (map (d: "/sysroot" + d) lowerdir)}; do if test -e "$d/$p"; then -- cgit v1.3.1