I'm creating logical volumes for export via targetcli (iSCSI).

I'm using lvm's thin provisioned volumes, e.g.

lvcreate -V 1T --thin -n vol_name storage/thin_pool

Then I add the created logical volume into targetcli's iblock backstore. The resulting device shows 4096 as get attribute hw_block_size

Due to lacking initiator support (VirtualBox) I need those LUNs to have 512-byte sectors. I'd like to avoid using fileio backstore (which supposedly allows setting sector size), for consistency reasons.

Is it possible to specify sector size during creation of the volume or assignment of the volume into backstore?


The fileio backing store driver is the way you would accomplish this. Consistency is only a concern if you choose to enable writeback caching (or as targetcli refers to it, "buffered mode") on the fileio backstores.

Unbuffered mode is the default for just about every targetcli implementation on any distro, as suggested by Datera itself. This shouldn't be a big deal.

However, if you need to force unbuffered mode for a particular backing object (and perhaps you should just to be safe), you can specify so thusly:

#> targetcli

/backstores/fileio/test_name> set attribute buffered=False

As for addressing the issue of block size, you may also freely edit the block_size attribute for a particular fileio backing store object:

/backstores/fileio/test_name> set attribute block_size=4096

You can use fileio backstores to address thin LVM2 (or really any other block device) while changing nearly any setting, while the block or iblock backstores are optimized to pass devices and their hardware properties "directly" to initiators. Block should perform better than fileio, as the implementation is leaner - it just lacks features like this because of that lean implementation. If you don't require setting these parameters, "block" should be used for block devices.


With regads to the question, the block size can be changed at time when the file system is to be created. Therefore, I believe, you should run mkfs.yourfs -b 512 /dev/mapper/<VGName>-<logical volume>where yourfs is type of your file system.

  • 1
    There is no filesystem on the block device which is shared via iSCSI. Only the initiator (client) creates one – velis Dec 6 '16 at 19:15
  • 1
    I guess, you need to run this command on the server, where you creating and formatting logical volumes. – Stuka Dec 7 '16 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.