Installing nixos libvirt headless

I’m trying to install NixOS in libvirt headless. I tried the command from this post: [Solved] How to install NixOS text-only in libvirt?, but nothing happens after it connects to the console.

I then tried with the following command:

sudo virt-install --name nixos --ram 4096 --vcpus=2 \
 --nographics --boot uefi \
 --extra-args='console=ttyS0,115200n8' --location=/var/lib/libvirt/boot/latest-nixos-minimal-x86_64-linux.iso \
 --disk path=/var/lib/libvirt/images/nixos.qcow2,size=40,bus=virtio,format=qcow2 

This allows me to see it booting, but it fails in nixos stage 1:

...
[    1.289710] sr 0:0:0:0: [sr0] scsi3-mmc drive: 4x/4x cd/rw xa/form2 tray
[    1.290193] cdrom: Uniform CD-ROM driver Revision: 3.20
kbd_mode: KDSKBMODE: Inappropriate ioctl for device
starting device mapper and LVM...
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
mounting tmpfs on /...
waiting for device /dev/root to appear...File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.File descriptor 3 (/nix/store/27i4vck6bhbff733q7pgc7pg14phsn5q-initrd-fsinfo) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 8 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
File descriptor 9 (/dev/console) leaked on lvm invocation. Parent PID 1: /nix/store/hivimsrgqill4jzhm797kbin2pafnfhw-extra-utils/bin/ash
.
Timed out waiting for device /dev/root, trying to mount anyway.
mounting /dev/root on /iso...
mount: mounting /dev/root on /mnt-root/iso failed: No such file or directory

An error occurred in stage 1 of the boot process, which must mount the
root filesystem on `/mnt-root' and then start stage 2.  Press one
of the following keys:

  r) to reboot immediately
  *) to ignore the error and continue

I tried removing the --boot=uefi option and add a --import option, but this doesn’t seem to make a difference. I’m stuck at this point, not sure how to diagnose this further.

Hey there, did you investigate further, and solve it? I, too, get this, in the following situation:

  • created server VM qcow2 virtual disk image like this with nixos-generators
packages.${system} = {
        serverVdisk = let diskSizeGb = 8; in nixos-generators.nixosGenerate ({
          format = "qcow";
          modules = [{
            virtualisation.diskSize = diskSizeGb * 1024;
          }];
        } // serverConfig);
      };
  • copied it over to server
  • started as system service (boots successully)
  • make changes to VM installation via deploy-rs like this
      deploy.nodes.server = {
        hostname = server-hostname;
        sshUser = username;
        sshOpts = [ "-p" (builtins.toString server-vm-ssh-port) ];

        profiles.system = {
          user = "root";
          path = deploy-rs.lib.${system}.activate.nixos nixosConfigurations.server;
        };
      };

where, of course nixosConfigurations.server = nixpkgs.lib.nixosSystem serverConfig; is the same config as for the VM disk image creation.

The deploy-rs deployment works fine, but after reboot, I get the very same (repeated) error as you (leaked on lvm invocation), with the same /mnt-root, with the same choice r or *.

Thanks for some feedback, and a happy new year, of course!

I’m interested in building a minimal NixOS setup that does not include SSH but instead works through a serial connection. I can establish a serial connection on an already installed system using the following configuration:

boot.kernelParams = [
  "console=tty1"
  "console=ttyS0,115200n8"
];

When installing NixOS, I noticed that the first screen of the graphical installer provides an option for a serial-console session, but it is not the default. Only after manually selecting this option through the graphical interface can I switch to Minicom and proceed with a headless serial installation.

Using

--extra-args='console=ttyS0,115200n8'

I encounter the same errors as mentioned in the original post. In contrast, Alpine Linux works with this setting out of the box.

Would it be possible to force the installer image to provide a serial port by default? I followed a guide by Vimjoyer to create a custom ISO that includes the above mentioned kernel parameters, but this did not resolve the issue.

I’m somewhat doubtful that an “out-of-the-box” solution exists for this. For reference, I’m using version 24.11.
EDIT 1: I actually have not yet gone through [Solved] How to install NixOS text-only in libvirt? mentioned in the OP.
EDIT 2: Now that I have I can say this thread remains valid.
I tried

virt-install --name=nixos \
--memory=8196 \
--vcpus=2 \
--disk /path/to/my-nixos-disk-image.qcow2,device=disk,bus=virtio,size=16 \
--cdrom=/path/to/latest-nixos-minimal-x86_64-linux.iso \
--os-type=generic  \
--boot=uefi \
--nographics \
--console pty,target_type=virtio

But this gives a different result for me, namely:

BdsDxe: loading Boot0001 "UEFI QEMU DVD-ROM QM00001 " from PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x0,0xFFFF,0x0)
BdsDxe: failed to load Boot0001 "UEFI QEMU DVD-ROM QM00001 " from PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x0,0xFFFF,0x0): Access Denied
BdsDxe: failed to load Boot0002 "UEFI Misc Device" from PciRoot(0x0)/Pci(0x1,0x3)/Pci(0x0,0x0): Not Found
BdsDxe: No bootable option or device was found.