iSCSI in ZFS Print E-mail
(1 vote, average: 5.00 out of 5)
Written by geekyS   
Sunday, 14 December 2008 15:09

This geekyfacts article explains the steps to create iSCSI volume in ZFS and the procedure to mount the iSCSI device in Linux and Solaris client. This article is presented under the assumption that reader has basic knowledge of ZFS terminologies and open-iscsi,


ZFS volumes can be shared as iSCSI target Lun’s over the network. All the features of ZFS filesystem like snapshot, compression, clone etc applies for ZFS volumes too. We are going to create ZFS volume, share it as iSCSI target device and mount it in Linux & Solaris client.

Creating ZFS Volume

# zfs create -s -V 1gb testpool/iscsivol

 

# zfs list
NAME USED AVAIL REFER MOUNTPOINT
testpool 12.4G 50G 30.5K /testpool
testpool/iscsivol 22.5K 50G 22.5K -
#

 

You should be seeing block and raw device file now under /dev/zvol/

 

# ls /dev/zvol/dsk/testpool/iscsivol
/dev/zvol/dsk/testpool/iscsivol

 

# ls /dev/zvol/rdsk/testpool/iscsivol
/dev/zvol/rdsk/testpool/iscsivol
 

 

Sharing ZFS Volume as iSCSI target

 

# zfs set shareiscsi=on testpool/iscsivol

 


# zfs get shareiscsi testpool/iscsivol
NAME PROPERTY VALUE SOURCE
testpool/iscsivol shareiSCSI on local

 

Enable the iSCSI daemon using svcadm if it is diabled

 

# svcs -a | grep iscsi
disabled Dec_08 svc:/network/iscsi_initiator:default
online Dec_10 svc:/system/iscsitgt:default
#

 

You can see the shared iSCSI target details using iscsitadm as below,

 

# iscsitadm list target -v
Target: testpool/iscsivol
iscsi Name: iqn.1986-03.com.sun:02:6d5743b4-2856-e931-85f3-8d458e4ea54c
Alias: testpool/iscsivol
Connections: 0
ACL list:
TPGT list:
LUN information:
LUN: 0
GUID: 0x0
VID: SUN
PID: SOLARIS
Type: disk
Size: 1.0G
Backing store: /dev/zvol/rdsk/testpool/iscsivol
Status: online


Mounting iSCSI device in solaris client

 

Enable iSCSI initiator daemon

 

# svcs -a | grep iscsi
disabled Dec_08 svc:/system/iscsitgt:default
disabled 19:49:37 svc:/network/iscsi_initiator:default

 

# svcadm enable svc:/network/iscsi_initiator:default

 

# svcs -a | grep iscsi
disabled Dec_08 svc:/system/iscsitgt:default
online 19:49:49 svc:/network/iscsi_initiator:default

 

#iscsiadm modify discovery --sendtargets enable

 

You need to provide the appropriate iSCSI target server ip in place of 192.168.10.10

 

#iscsiadm add discovery-address 192.168.10.10

 

You should be seeing iSCSI target details discovered from 192.168.10.10

 

# iscsiadm list target
Target: iqn.1986-03.com.sun:02:6d5743b4-2856-e931-85f3-8d458e4ea54c
Alias: testpool/iscsivol
TPGT: 1
ISID: 4000002a0000
Connections

 

 

# format
Searching for disks...done


AVAILABLE DISK SELECTIONS:
.........

1. c2t01000019B90E2A3600002A0049457915d0
/scsi_vhci/disk@g01000019b90e2a3600002a0049457915
Specify disk (enter its number): 1
selecting c2t01000019B90E2A3600002A0049457915d0
[disk formatted]

Mounting iSCSI device in Linux Client

 

# Install open-iscsi initiator rpm

 

Discover the iSCSI target via send targets discovery method

 

# iscsiadm -m discovery -t st -p 10.176.86.200
10.176.86.200:3260,1 iqn.1986-03.com.sun:02:6d5743b4-2856-e931-85f3-8d458e4ea54c

 

# iscsiadm -m node
10.176.86.200:3260,1 iqn.1986-03.com.sun:02:6d5743b4-2856-e931-85f3-8d458e4ea54c

 

Make iSCSI device accessible to the client,

 

# iscsiadm -m node -T iqn.1986-03.com.sun:02:6d5743b4-2856-e931-85f3-8d458e4ea54c -p 10.176.86.200:3260 --login

 

You should be seeing the following message in /var/log/messages,

 

# tail /var/log/messages
......

Dec 14 15:02:04 kernel: sd 16:0:0:0: Attached scsi disk sdb
Dec 14 15:02:04 kernel: sd 16:0:0:0: Attached scsi generic sg2 type 0

 

 

Create Linux partition using fdisk

 

# fdisk /dev/sdb

 

Create ext3 file system in /dev/sdb

 

# mkfs.ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
......

 

# mount /dev/sdb1 /mnt

 

# df -h /mnt
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 1006M 18M 938M 2% /mnt

Last Updated on Monday, 22 December 2008 08:37