Env: ==== FreeBSD san.dev.enaza.ru 11.0-STABLE FreeBSD 11.0-STABLE #0 r315957: Wed Nov 1 15:14:39 +05 2017 emz@san.dev.enaza.ru:/usr/obj/usr/src/sys/GENERIC amd64 ctld is often assigning duplicate serials and lun-id on luns after ctladm remove has been issued. This leads to confusion on initiators. I'm not sure if it's a bug from the iSCSI protocol point of view, but from user side it definitely is. # ctladm devlist -v LUN Backend Size (Blocks) BS Serial Number Device ID 1 block 6442450944 512 MYSERIAL 1 MYDEVID 1 lun_type=0 num_threads=14 file=/dev/zvol/dataflash/games-ver5_27-worker01 ctld_name=iqn.2016-04.net.playkey.iscsi:games-worker01,lun,0 scsiname=iqn.2016-04.net.playkey.iscsi:games-worker01,lun,0 2 block 6442450944 512 MYSERIAL 2 MYDEVID 2 lun_type=0 num_threads=14 file=/dev/zvol/dataflash/games-ver5_27-worker02 ctld_name=iqn.2016-04.net.playkey.iscsi:games-worker02,lun,0 scsiname=iqn.2016-04.net.playkey.iscsi:games-worker02,lun,0 3 block 6442450944 512 MYSERIAL 3 MYDEVID 3 lun_type=0 num_threads=14 file=/dev/zvol/dataflash/games-ver5_27-worker03 ctld_name=iqn.2016-04.net.playkey.iscsi:games-worker03,lun,0 scsiname=iqn.2016-04.net.playkey.iscsi:games-worker03,lun,0 4 block 6442450944 512 MYSERIAL 4 MYDEVID 4 lun_type=0 num_threads=14 file=/dev/zvol/dataflash/games-ver5_27-worker04 ctld_name=iqn.2016-04.net.playkey.iscsi:games-worker04,lun,0 scsiname=iqn.2016-04.net.playkey.iscsi:games-worker04,lun,0 5 block 6442450944 512 MYSERIAL 5 MYDEVID 5 lun_type=0 num_threads=14 file=/dev/zvol/dataflash/games-ver12_2-worker05 ctld_name=iqn.2016-04.net.playkey.iscsi:games-worker05,lun,0 scsiname=iqn.2016-04.net.playkey.iscsi:games-worker05,lun,0 7 block 104857600 512 MYSERIAL 7 MYDEVID 7 lun_type=0 num_threads=14 scsiname=userdata1 file=/dev/zvol/data/userdata1 ctld_name=iqn.2016-04.net.playkey.iscsi:userdata1,lun,0 8 block 104857600 512 MYSERIAL 8 MYDEVID 8 lun_type=0 num_threads=14 scsiname=userdata2 file=/dev/zvol/data/userdata2 ctld_name=iqn.2016-04.net.playkey.iscsi:userdata2,lun,0 9 block 2048 512 MYSERIAL 9 MYDEVID 9 lun_type=0 num_threads=14 file=/dev/zvol/dataflash/foobar ctld_name=iqn.2016-04.net.playkey.iscsi:foobar,lun,0 scsiname=iqn.2016-04.net.playkey.iscsi:foobar,lun,0 10 block 104857600 512 MYSERIAL 10 MYDEVID 10 lun_type=0 num_threads=14 file=/dev/zvol/dataflash/kvm/guest1 ctld_name=iqn.2016-04.net.playkey.iscsi:guest1,lun,0 scsiname=iqn.2016-04.net.playkey.iscsi:guest1,lun,0 11 block 104857600 512 MYSERIAL 11 MYDEVID 11 lun_type=0 num_threads=14 file=/dev/zvol/dataflash/kvm/guest2 ctld_name=iqn.2016-04.net.playkey.iscsi:guest2,lun,0 scsiname=iqn.2016-04.net.playkey.iscsi:guest2,lun,0 12 block 104857600 512 MYSERIAL 12 MYDEVID 12 lun_type=0 num_threads=14 file=/dev/zvol/dataflash/kvm/guest3 ctld_name=iqn.2016-04.net.playkey.iscsi:guest3,lun,0 scsiname=iqn.2016-04.net.playkey.iscsi:guest3,lun,0 0 block 6442450944 512 MYSERIAL 11 MYDEVID 11 lun_type=0 num_threads=14 file=/dev/zvol/dataflash/games ctld_name=iqn.2016-04.net.playkey.iscsi:games,lun,0 scsiname=iqn.2016-04.net.playkey.iscsi:games,lun,0 15 block 104857600 512 MYSERIAL 12 guest4 lun_type=0 num_threads=14 file=/dev/zvol/dataflash/kvm/guest4 ctld_name=iqn.2016-04.net.playkey.iscsi:guest4,lun,0 scsiname=iqn.2016-04.net.playkey.iscsi:guest4,lun,0
This is probably not a bug. I don't think there's anything in the SCSI model that requires every device to have a unique and persistent serial number. However, VMWare ESX assumes otherwise. So it would be a useful enhancement if ctld could generate unique serial numbers for every LUN. VMWare will refuse to use two different iSCSI LUNs that share the same serial number. https://www.reddit.com/r/freenas/comments/k3n33p/vmware_users_beware_this_iscsi_lun_bug_causing/