vHoge

VMwareのアレコレ備忘録。CLIでがんばるネタ多め。

tgt で作る iSCSI 領域の block size を変更したい

どうやるんだっけメモ。

デフォルト

こういう tgt の conf だと

<target raspi01.home.lab>
  backing-store /dev/sda
  initiator-address 192.168.100.0/24
  write-cache on
</target>

こうなる。

mirie@raspi01:~$ sudo tgtadm --mode target --op show
Target 1: raspi01.home.lab
    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: IET     00010000
            SCSI SN: beaf10
            Size: 0 MB, Block size: 1
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            SWP: No
            Thin-provisioning: No
            Backing store type: null
            Backing store path: None
            Backing store flags:
        LUN: 1
            Type: disk
            SCSI ID: IET     00010001
            SCSI SN: beaf11
            Size: 2000399 MB, Block size: 512
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            SWP: No
            Thin-provisioning: No
            Backing store type: rdwr
            Backing store path: /dev/sda
            Backing store flags:
    Account information:
    ACL information:
        192.168.100.0/24

Block size 512 って小さいよね…
大きくしたいんだけど、どう書くんだっけ。

正しい書き方

man target.confを読めと。
Target-Level Directives では指定できず、Lun-level Directives で指定可能らしい。
なので少し構成を変更。

<target raspi01.home.lab>
  initiator-address 192.168.100.0/24
  write-cache on
  <backing-store /dev/sda>
    lun 1
    block-size 4096
  </backsing-store>
</target>

1階層落とす感じ。

mirie@raspi01:~$ sudo tgtadm --mode target --op show
Target 1: raspi01.home.lab
    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: IET     00010000
            SCSI SN: beaf10
            Size: 0 MB, Block size: 1
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            SWP: No
            Thin-provisioning: No
            Backing store type: null
            Backing store path: None
            Backing store flags:
        LUN: 1
            Type: disk
            SCSI ID: IET     00010001
            SCSI SN: beaf11
            Size: 2000399 MB, Block size: 4096
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            SWP: No
            Thin-provisioning: No
            Backing store type: rdwr
            Backing store path: /dev/sda
            Backing store flags:
    Account information:
    ACL information:
        192.168.100.0/24

これで Block size が 4096 に。