Lvm – How to specify sector size for LVM logical volume

iscsilvm

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?

Best Answer

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.