I’m writing a custom disk image builder based on make-disk-image.nix with support for LVM and LUKS.
Unfortunately, I’ve hit a roadblock as I can’t seem to create LVM logical volumes under the builder VM.
When I do something like lvcreate -L4G -n myVol myVg
, I get:
++ parted -s /dev/vda -- mklabel msdos mkpart primary 2048s 100%
++ pvcreate /dev/vda1
Physical volume "/dev/vda1" successfully created.
++ vgcreate system /dev/vda1
Volume group "system" successfully created
++ lvcreate -L 128M -n boot system
/dev/system/boot: not found: device not cleared
Aborting. Failed to wipe start of new LV.
I initially thought of doing it like the original one does and set up all the partitions during prepareImage
(which is executed in the host Nix system) but realized that it won’t work because doing so would be impure and the Nix builder user cannot execute LVM commands anyway, so I needed to do it inside the builder VM.
I do understand that the builder VM is running a very minimal NixOS system (I’ve read the stage1/2 init scripts) and some research says it might have to do with udev
not running. But before I attempt to turn runInLinuxVM
inside-out and write my own version, I wanted to hear if somebody has had success with this topic before.