Skip to content

make-disk-image.nix: cannot initialize fsdev 'sa' #359782

@yellowhat

Description

@yellowhat

Describe the bug

Hi,
consider the following files:

flake.nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  };

  outputs = { nixpkgs, ... }@attrs:
    let
      system = "x86_64-linux";
    in {
      nixosConfigurations = {
        qcow2 = nixpkgs.lib.nixosSystem {
          inherit system;
          modules = [ ./qcow2.nix ];
        };
      };
    };
}
qcow2.nix
{
  config,
  lib,
  pkgs,
  modulesPath,
  ...
}:
{

  imports = [ "${modulesPath}/profiles/qemu-guest.nix" ];

  boot = {
    loader.systemd-boot.enable = true;
    kernelPackages = pkgs.linuxPackages_6_11;
  };

  # These labels are set/expected by `make-disk-image.nix`
  fileSystems = {
    "/boot" = {
      device = "/dev/disk/by-label/ESP";
      fsType = "vfat";
    };
    "/" = {
      device = "/dev/disk/by-label/nixos";
      fsType = "ext4";
      autoResize = true;
    };
  };

  system.build.qcow2 = import "${modulesPath}/../lib/make-disk-image.nix" {
    inherit config lib pkgs;
    diskSize = 20480;
    format = "qcow2-compressed";
    partitionTableType = "efi";
    copyChannel = false;
  };
}

after updating to the latest nixos-unstable:

flake.lock
{
  "nodes": {
    "nixpkgs": {
      "locked": {
        "lastModified": 1732521221,
        "narHash": "sha256-2ThgXBUXAE1oFsVATK1ZX9IjPcS4nKFOAjhPNKuiMn0=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "4633a7c72337ea8fd23a4f2ba3972865e3ec685d",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "nixpkgs": "nixpkgs"
      }
    }
  },
  "root": "root",
  "version": 7
}

If I run:

nix build .#nixosConfigurations.qcow2.config.system.build.qcow2 --print-build-logs

I get the following error:

nixos-disk-image> WARNING: Image format was not specified for 'nixos.raw' and probing guessed raw.
nixos-disk-image>          Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
nixos-disk-image>          Specify the 'raw' format explicitly to remove the restrictions.
nixos-disk-image> qemu-kvm: -virtfs local,path=/build,security_model=none,mount_tag=sa: cannot initialize fsdev 'sa': failed to open '/build': No such file or directory
error: builder for '/nix/store/nyvlsqnawm657ddfz9kswgxdylvkk8lr-nixos-disk-image.drv' failed with exit code 1

If I revert to nixos-unstable:

flake.lock
{
  "nodes": {
    "nixpkgs": {
      "locked": {
        "lastModified": 1732014248,
        "narHash": "sha256-y/MEyuJ5oBWrWAic/14LaIr/u5E0wRVzyYsouYY3W6w=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "23e89b7da85c3640bbc2173fe04f4bd114342367",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "nixpkgs": "nixpkgs"
      }
    }
  },
  "root": "root",
  "version": 7
}

It works as expected:

nixos-disk-image> WARNING: Image format was not specified for 'nixos.raw' and probing guessed raw.
nixos-disk-image>          Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
nixos-disk-image>          Specify the 'raw' format explicitly to remove the restrictions.
nixos-disk-image> cSeaBIOS (version rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org)
nixos-disk-image> iPXE (http://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+3EFD0CF0+3EF30CF0 CA00
nixos-disk-image> Booting from ROM...
nixos-disk-image> Probing EDD (edd=off to disable)... ocloading kernel modules...
nixos-disk-image> mounting Nix store...
nixos-disk-image> mounting host's temporary directory...
nixos-disk-image> starting stage 2 (/nix/store/mslzxrnwm7hmykqkrryyq0nj4rk45845-vm-run-stage2)
nixos-disk-image> tune2fs 1.47.1 (20-May-2024)
nixos-disk-image> Setting maximal mount count to -1
nixos-disk-image> Setting interval between checks to 0 seconds
nixos-disk-image> Setting time filesystem last checked to Thu Nov 28 08:10:35 2024
nixos-disk-image> mkfs.fat 4.2 (2021-01-31)
nixos-disk-image> setting up /etc...
nixos-disk-image> Initializing machine ID from random generator.
nixos-disk-image> Created "/boot/EFI".
nixos-disk-image> Created "/boot/EFI/systemd".
nixos-disk-image> Created "/boot/EFI/BOOT".
nixos-disk-image> Created "/boot/loader".
nixos-disk-image> Created "/boot/loader/entries".
nixos-disk-image> Created "/boot/EFI/Linux".
nixos-disk-image> Copied "/nix/store/ivqjhj99firnjq7gp14qf35821viwi5m-systemd-256.7/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/EFI/systemd/systemd-bootx64.efi".
nixos-disk-image> Copied "/nix/store/ivqjhj99firnjq7gp14qf35821viwi5m-systemd-256.7/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/EFI/BOOT/BOOTX64.EFI".
nixos-disk-image> ⚠️ Mount point '/boot' which backs the random seed file is world accessible, which is a security hole! ⚠️
nixos-disk-image> ⚠️ Random seed file '/boot/loader/.#bootctlrandom-seed3eccc68721bd85ee' is world accessible, which is a security hole! ⚠️
nixos-disk-image> Random seed file /boot/loader/random-seed successfully written (32 bytes).
nixos-disk-image> tune2fs 1.47.1 (20-May-2024)
nixos-disk-image> Setting maximal mount count to -1
nixos-disk-image> Setting interval between checks to 0 seconds
nixos-disk-image> Setting time filesystem last checked to Thu Nov 28 08:10:36 2024
nixos-disk-image> tune2fs 1.47.1 (20-May-2024)
nixos-disk-image> Setting time filesystem last checked to Thu Jan  1 00:00:00 1970
nixos-disk-image> [    2.623511] reboot: Power down

Metadata

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.11.9`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.25.2`
 - channels(root): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`

Notify maintainers

@phaer


Note for maintainers: Please tag this issue in your PR.


Add a 👍 reaction to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions