From 7f026cc6d02746d553e5e3701d44fc89869bc7af Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Mon, 5 Sep 2022 17:10:59 -0700 Subject: [PATCH] qemu-vm: ensure we do not overwrite the partition table when EFI is in use --- nixos/modules/virtualisation/qemu-vm.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index 0207bfba82ad..b2e10da6891e 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -858,7 +858,8 @@ in # If the disk image appears to be empty, run mke2fs to # initialise. FSTYPE=$(blkid -o value -s TYPE ${cfg.bootDevice} || true) - if test -z "$FSTYPE"; then + PARTTYPE=$(blkid -o value -s PTTYPE ${cfg.bootDevice} || true) + if test -z "$FSTYPE" -a -z "$PARTTYPE"; then mke2fs -t ext4 ${cfg.bootDevice} fi '';