Ubuntu Server 18.04 LTS 기반에서 iSCSI Target을 이용한 diskless system을 만들려고 한다. iSCSI Target의 설치 및 설정 과정은 다음과 같이 진행된다. 여기서는, 새로운 iSCSI Target 생성 다룬다. 



2-3 새로운 iSCSI Target 생성


iSCSI Target의 소프트웨어 패키지를 설치하고, iSCSI Initiator에게 제공할 디스크 이미지를 생성하였다. iSCSI Initiator에게 디스크 이미지를 제공하기 위해서, iSCSI Target의 설정이 필요하다. 많은 설정 사항들이 있지만, 필요한 부분만을 다음과 같이 설정한다. 

1) 새로운 Target의 이름 및 id (tid) 를 생성
2) tid에 대응되는 logicalunit에 디스크 이미지 연결
3) tid 접속 허가 설정

새로운 Target의 이름 id인 tid를 설정하는 명령어와 옵션은 다음과 같다. 해당 명령에 대한 설명과 옵션은 본문의 아래에 표기한 레퍼런스에서 찾을 수 있다. 

tgtadm --lld iscsi --op new --mode target --tid 80 -T iqn.server.ubuntu:duripc80

위의 명령에서는 새로운 Target의 드라이버 이름은 iscsi로 하고, tid를 80번으로 하고, iSCSI Qualified Name (iqn) 을 iqn.server.ubuntu:duri로 설정한 것이다. iqn 이름은 임의로 설정해도 무관하다. 단, iSCSI Initiator에서 스크립트 방법으로 iSCSI Target에 접속할 때 iqn 이름이 이용되기 때문에 기억하고 있어야 한다. 설정된 정보는 다음 두가지 방법의 명령으로 확인된다. 

tgtadm --lld iscsi --op show --mode target

tgt-admin -s

Target 80: iqn.server.ubuntu:duripc80
    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: IET     00500000
            SCSI SN: beaf800
            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:
    Account information:
    ACL information:

설정된 정보에서 logicalunit인 LUN이 0 인 것을 확인 할 수 있다. lun0은 자동으로 생성되는 특정 디바이스를 위해 예약되어 있다고 한다. 16.04 LTS 버전에서는 LUN0 부터 이미지가 등록되었지만, 18.04 LTS 부터는 사용자 이미지는 LUN1 부터 등록된다. 따라서, 위에서 생성한 새로운 Target은 드라이버 명, tid, iqn이 설정된 것이다. 생성된 tid에 추가로 iSCSI Initiator에 제공할 이미지를 LUN1, LUN2,... 등으로 하여 등록할 수 있다. 다음 명령은 생성된 tid 80에 /iscsi1/disk1/disk.img 를 LUN1으로 연결시키는 명령이다. 필자는 이미지를 3개를 준비하였기 때문에 LUN1, LUN2, LUN3을 추가하였다. 

tgtadm --lld iscsi --op new --mode logicalunit --tid 80 --lun 1 -b /iscsi1/disk1/disk.img
tgtadm --lld iscsi --op new --mode logicalunit --tid 80 --lun 2 -b /iscsi2/disk2/disk.img
tgtadm --lld iscsi --op new --mode logicalunit --tid 80 --lun 3 -b /iscsi3/disk3/disk.img

실행 결과, 설정된 정보는 아래와 같다. 

Target 80: iqn.server.ubuntu:duripc80

    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: IET     00500000
            SCSI SN: beaf800
            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     00500001
            SCSI SN: beaf801
            Size: 386547 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: /iscsi1/disk1/disk.img
            Backing store flags:
        LUN: 2
            Type: disk
            SCSI ID: IET     00500002
            SCSI SN: beaf802
            Size: 386547 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: /iscsi2/disk2/disk.img
            Backing store flags:
        LUN: 3
            Type: disk
            SCSI ID: IET     00500003
            SCSI SN: beaf803
            Size: 386547 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: /iscsi3/disk3/disk.img
            Backing store flags:
    Account information:
    ACL information:


마지막으로 접속을 허용할 iSCSI Initiator에 관한 정보를 설정한다. 여기에서는 iSCSI Initiator PC의 이름 또는 IP를 설정하여 tid에 대한 허가 범위를 설정 할 수 있다. 아래 명령은 IP로 하여 tid 80의 허가를 설정하는 명령이다. 


tgtadm --lld iscsi --op bind --mode target --tid 80 -I 210.182.xxx.xxx


위 명령이 실행되면, LUN을 추가한 결과 중 가장 아래의 ACL information에 허가할 IP가 추가된다. 

    ACL information:

        210.182.xxx.xxx


이렇게 하면, 하나의 Target이 생성된 것이고, 연결할 iSCSI Initiator PC의 수에 따라 여러개 Target을 생성할 수 있다.  


생성된 Target을 삭제하는 명령은 다음과 같다. 


tgtadm --lld iscsi --op delete --mode target --tid 80


단, iSCSI Initiator에 의해 해당 Target이 액세스 되고 있다면, 삭제될 수 없다. 이 경우, 다음의 명령과 같이 옵션을 주어 강제로 삭제할 수 있다. 


tgtadm --lld iscsi --op delete --force --mode target --tid 80


References, 

[1] The iSCSI Enterprise Target Project, http://iscsitarget.sourceforge.net/

[2] tgt project, http://stgt.sourceforge.net/

[3] Linux-iSCSI Project, http://linux-iscsi.sourceforge.net/

[4] tgtadm - Linux SCSI Target Administration Utility, 
http://manpages.ubuntu.com/manpages/bionic/man8/tgtadm.8.html#name

[5] tgt-admin - Linux SCSI Target Configuration Tool, 
http://manpages.ubuntu.com/manpages/bionic/man8/tgt-admin.8.html

[6] btrfs - a toolbox to manage btrfs filesystems, 
http://manpages.ubuntu.com/manpages/bionic/en/man8/btrfs.8.html



Posted by 두리PC
,