[SOLVED] iscsi direct lun: vm has wrong partition layout

yoshi_26_02

Member
Mar 16, 2019
2
0
6
23
I am currently setting up iSCSI storage with direct LUNs.
However, VM does not detect any partition (the LUNs already have data on them).

I experimented and found that if I create a MBR table (rather than GPT) with a single partition, the VM detects the partition but with an invalid size.

Host has correct partition layout (15G partition):
Code:
NAME     MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sdd        8:48   0   15G  0 disk
`-sdd1     8:49   0   15G  0 part

VM has wrong layout (1.9G partition):
Code:
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0    15G  0 disk
└─sda1   8:1    0   1.9G  0 part

I configured the VM and choose the iSCSI LUN with the web UI.

Do you have any idea about why is this occurring?

Thank you for any help

Full lsblk for host:
Code:
NAME   KNAME PATH      MAJ:MIN FSAVAIL FSSIZE FSTYPE FSUSED FSUSE% FSVER MOUNTPOINT LABEL   UUID                                 PTUUID                               PTTYPE PARTTYPE PARTTYPENAME PARTLABEL PARTUUID                             PARTFLAGS   RA RO RM HOTPLUG MODEL      SERIAL          SIZE STATE   OWNER GROUP MODE       ALIGNMENT MIN-IO  OPT-IO PHY-SEC LOG-SEC ROTA SCHED       RQ-SIZE TYPE DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO WSAME WWN                                RAND PKNAME HCTL       TRAN   SUBSYSTEMS  REV VENDOR   ZONED DAX
sdd    sdd   /dev/sdd    8:48                                                                                                    15eb9d87                             dos                                                                                   2048  0  0       0 iSCSI_Disk 00259083c7e8008  15G running root  disk  brw-rw----         0  16384 1048576   16384    4096    0 mq-deadline     226 disk        0       16K      32G         0   32G 0x6589cfc000000ce253a94872d54008ba    0        9:0:0:0    iscsi  block:scsi 0123 TrueNAS  none    0
`-sdd1 sdd1  /dev/sdd1   8:49                 ext4                 1.0              EXTTEST bfd155ca-8cdf-47ac-ba11-9822422b7942 15eb9d87                             dos    0x83     Linux                  15eb9d87-01                                    2048  0  0       0                             15G         root  disk  brw-rw----         0  16384 1048576   16384    4096    0 mq-deadline     226 part        0       16K      32G         0   32G 0x6589cfc000000ce253a94872d54008ba    0 sdd                      block:scsi               none    0

Full lsblk for VM:
Code:
NAME   KNAME PATH      MAJ:MIN FSAVAIL FSSIZE FSTYPE FSUSED FSUSE% FSVER MOUNTPOINT LABEL UUID PTUUID                               PTTYPE PARTTYPE PARTTYPENAME PARTLABEL PARTUUID                             PARTFLAGS  RA RO RM HOTPLUG MODEL         SERIAL       SIZE STATE   OWNER GROUP MODE       ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED RQ-SIZE TYPE DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO WSAME WWN RAND PKNAME HCTL       TRAN SUBSYSTEMS             REV VENDOR   ZONED DAX
sda    sda   /dev/sda    8:0                                                                   15eb9d87                             dos                                                                                   128  0  0       0 QEMU_HARDDISK drive-scsi0   15G running root  disk  brw-rw----         0    512      0     512     512    0 none      256 disk        0        4K       1G         0    2G        0        6:0:0:0         block:scsi:virtio:pci 2.5+ QEMU     none    0
└─sda1 sda1  /dev/sda1   8:1                                                                   15eb9d87                             dos    0x83     Linux                  15eb9d87-01                                    128  0  0       0                            1.9G         root  disk  brw-rw----         0    512      0     512     512    0 none      256 part        0        4K       1G         0    2G        0 sda                    block:scsi:virtio:pci               none    0
 

yoshi_26_02

Member
Mar 16, 2019
2
0
6
23
Problem solved:

The logical block size were different between the host and the VM, which was causing addressing inconsistencies on the block device.

The VM was detecting block sizes of 512 logical and 512 physical, while the true block sizes on the host was 4096 logical and 16384 physical.
This explains the difference in partition size: 1.9G * 8 =~ 15G.

I fixed the issue by adding arguments to override the block sizes in the VM config file:
Code:
args: -set device.scsi0.logical_block_size=4096 -set device.scsi0.physical_block_size=16384
This must be done for all SCSI devices which are passed from host devices (e.g. iSCSI direct LUNs), if they don't have 512/512 block sizes.

Note: the fastest way I found to check block sizes is with lsblk -t.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!