iSCSI TargetをUbuntu 12.04にセットアップ


[bash]
$ sudo apt-get update
$ sudo apt-get install iscsitarget
$ dpkg -l iscsitarget
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
ii iscsitarget 1.4.20.2-10u amd64 iSCSI Enterprise Target userland
$ sudo vi /etc/default/iscsitarget 
ISCSITARGET_ENABLE=true
$ dd if=/dev/zero of=iscsi.img count=0 bs=1 seek=1G
$ sudo vi /etc/iet/ietd.conf
(末尾に追記)
Target iqn.2013-08.me.hrendoh:test.disk
Lun 0 Path=/home/cloudn/iscsi.img,Type=fileio
$ sudo service iscsitarget restart
* Removing iSCSI enterprise target devices: [ OK ]
* Starting iSCSI enterprise target service FATAL: Module iscsi_trgt not found.
[fail]</pre>
起動しようとするとエラー「FATAL: Module iscsi_trgt not found.」
iscsitarget-dkmsをインストールすると解消する(参考:<a href="http://www.heath-bar.com/blog/?p=203">Setup an Ubuntu iSCSI target (server)</a>)
<pre>$ sudo apt-get install iscsitarget-dkms
$ sudo service iscsitarget restart
* Removing iSCSI enterprise target devices: [ OK ]
* Starting iSCSI enterprise target service [ OK ]
[ OK ]
[/bash]
Firewallを設定

1.2.3.xのアクセスをCIDRで指定(Cloudnを利用)

iSCSIターゲット用Firewall設定 Cloudn
iSCSIターゲット用Firewall設定 Cloudn

Ufwなら
[bash]
$ ufw allow from 111.222.333.0/24 to any port 3260
[/bash]

追加ディスクを利用する場合

[bash]
$ sudo fdisk -l

Disk /dev/vda: 16.1 GB, 16106127360 bytes
16 heads, 63 sectors/track, 31207 cylinders, total 31457280 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000e1e29

Device Boot Start End Blocks Id System
/dev/vda1 * 2048 499711 248832 83 Linux
/dev/vda2 501758 31455231 15476737 5 Extended
/dev/vda5 501760 31455231 15476736 8e Linux LVM

Disk /dev/vdb: 107.4 GB, 107374182400 bytes
16 heads, 63 sectors/track, 208050 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/vdb doesn’t contain a valid partition table

Disk /dev/mapper/localhost-root: 13.7 GB, 13652459520 bytes
255 heads, 63 sectors/track, 1659 cylinders, total 26664960 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/localhost-root doesn’t contain a valid partition table

Disk /dev/mapper/localhost-swap_1: 2143 MB, 2143289344 bytes
255 heads, 63 sectors/track, 260 cylinders, total 4186112 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/localhost-swap_1 doesn’t contain a valid partition table
$ sudo vi /etc/iet/ietd.conf
Target iqn.2013-08.me.hrendoh:test.disk
Lun 0 Path=/dev/vdb,Type=blockio
$ sudo service iscsitarget restart
[/bash]

,