How does LBA of LUN mapped to image file of iSCSI file-based target

503 views Asked by At

I created a file based target by dd a file and mapped to a iSCSI target. It was done by the example from here

dd if=/dev/zero of=/root/os.img bs=1G count=10
Target iqn.2010-06.ServerName:desc
Lun 0 Path=/root/os.img,Type=fileio

I can see the packages between windows (iSCSI initiator) and iSCSI target from wireshark.

My question is how does the address iSCSI initiator tries to access (LBA) mapped to the image file (os.img) ? Will there be meta-data in LUN ?

1

There are 1 answers

0
Mike Andrews On BEST ANSWER

There's no additional metadata. When you access logical block address (LBA) 0 on your initiator, you're accessing offset 0 in that 10G file you created. When you access the LBA at 10MiB into the LUN, you're accessing the block at the offset 10MiB into os.img. Blocks are 512 bytes.

To use the LUN, you'll likely need to format it with a filesystem. The filesystem contains metadata like filenames, attributes, and which blocks are mapped to them.

If you're thinking about thin-provisioning metadata for the LUN itself, you have some in a roundabout way because your LUN is stored as a file (os.img) on a filesystem (whatever contains /root). The filesystem keeps track of what blocks in the file are allocated. But, since you created it by using dd, you've already allocated all of its blocks. You could avoid that by creating a sparse file for the lun like this:

truncate -s 10G os.img

(courtesy Quickly create a large file on a Linux system?)

But, other than those two tangentially related examples, there's no metadata.