Assign LUNs starting at zero on each target Start numbering SCSI LUNs from zero on each target (really on each controller, as the target [SCSI ID] is hard-coded as zero). Using `$drive->{index}` as the LUN number results in targets with an arbitrary gap in LUN numbering. Use `$unit` instead as it resets per controller. Normal SCSI hardware is always required to implement LUN 0 to at least report the number of LUNs on the target. It is unusual that there would be gaps in the LUN numbering of available (and present) LUNs. Not all SCSI subsystems can readily deal with a sparse LUN space. For example, NetBSD and OpenBSD will stop scanning further LUNs when a LUN reports either "NOT PRESENT" or "NO DEVICE". Qemu, when configured to use a disk with a LUN higher than 0 and with nothing configured on LUN 0 of the same target, reports both flags for LUN 0, resulting in the disk not being attached. (FreeBSD appears to always scan up to 8 LUNs.) > dpkg -S /usr/share/perl5/PVE/QemuServer.pm qemu-server: /usr/share/perl5/PVE/QemuServer.pm > dpkg -s qemu-server | grep ^Version: Version: 6.2-10 --- /usr/share/perl5/PVE/QemuServer.pm.ORIG 2020-07-13 14:37:37.000000000 +0300 +++ /usr/share/perl5/PVE/QemuServer.pm 2020-07-16 08:45:23.606572767 +0300 @@ -1352,7 +1352,7 @@ sub print_drivedevice_full { if (!$conf->{scsihw} || ($conf->{scsihw} =~ m/^lsi/)){ $device = "scsi-$devicetype,bus=$controller_prefix$controller.0,scsi-id=$unit,drive=drive-$drive->{interface}$drive->{index},id=$drive->{interface}$drive->{index}"; } else { - $device = "scsi-$devicetype,bus=$controller_prefix$controller.0,channel=0,scsi-id=0,lun=$drive->{index},drive=drive-$drive->{interface}$drive->{index},id=$drive->{interface}$drive->{index}"; + $device = "scsi-$devicetype,bus=$controller_prefix$controller.0,channel=0,scsi-id=0,lun=$unit,drive=drive-$drive->{interface}$drive->{index},id=$drive->{interface}$drive->{index}"; } if ($drive->{ssd} && ($devicetype eq 'block' || $devicetype eq 'hd')) {