Custom Search

Tuesday, January 8, 2013

how to setup iscsi with ubuntu linux

saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ cat /proc/partitions
major minor  #blocks  name

   7        1    2048000 loop1
   8        0  488386584 sda
   8        1  102400000 sda1
   8        2  102400000 sda2
   8        3  102400000 sda3
   8        4          1 sda4
   8        5  102400000 sda5
   8        6   78781440 sda6
  11        0    1048575 sr0
   8       16  488386584 sdb
 252        0    1048576 dm-0
saju@saju-desktop:/mnt/iscsi$

-------------------------------------


1) Setup iSCSI Target
================

saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ sudo dd if=/dev/zero of=/mnt/iscsi/mydisk bs=100M count=20
20+0 records in
20+0 records out
2097152000 bytes (2.1 GB) copied, 19.2759 s, 109 MB/s
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$

---------------------------

saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ sudo losetup /dev/loop1 /mnt/iscsi/mydisk
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$

---------------------------

# create a phisical volume
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ sudo pvcreate /dev/loop1
  Physical volume "/dev/loop1" successfully created
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$

---------------------------

# create a volume group named "myvolume-group1"
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ sudo vgcreate -s 32M myvolume-group1 /dev/loop1
  Volume group "myvolume-group1" successfully created
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$

---------------------------

# create a logical volume named "mylogical_volume1"
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ sudo lvcreate -L 1G -n mylogical_volume1 myvolume-group1
  Logical volume "mylogical_volume1" created
saju@saju-desktop:/mnt/iscsi$

---------------------------

saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ sudo apt-get install iscsitarget iscsitarget-dkms
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$

---------------------------

##Enable ISCSITARGET_ENABLE
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ sudo vim /etc/default/iscsitarget
ISCSITARGET_ENABLE=true

---------------------------

saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ sudo vim /etc/iet/ietd.conf
# add at the last
# naming rule : [ iqn.yaer-month.domain:any name ]
Target iqn.2012-07.world.server:target0
# provided devicce as a iSCSI target
Lun 0 Path=/dev/myvolume-group1/mylogical_volume1,Type=blockio
# iSCSI Initiator's IP address you allow to connect
initiator-address 127.0.0.1
# authentication info ( set anyone you like for "username", "password" )
incominguser saju1 saju1


---------------------------

saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ sudo service iscsitarget restart
 * Removing iSCSI enterprise target devices:                                                                                          [ OK ]
 * Starting iSCSI enterprise target service                                                                                           [ OK ]
                                                                                                                                      [ OK ]
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$

---------------------------

# confirm status
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ sudo ietadm --op show --tid=1
Wthreads=8
Type=0
QueuedCommands=32
NOPInterval=0
NOPTimeout=0
saju@saju-desktop:/mnt/iscsi
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$


 2) Setup iSCSI Initiator
==================

saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ sudo apt-get install open-iscsi
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$

---------------------------

saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ sudo vim /etc/iscsi/iscsid.conf

# line 39: uncomment
node.session.auth.authmethod = CHAP

# line 43,44: uncomment and set username and password which set on iSCSI Target
node.session.auth.username = saju1
node.session.auth.password = saju1


---------------------------

#### discover target
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ sudo iscsiadm -m discovery -t sendtargets -p 127.0.0.1
127.0.0.1:3260,1 iqn.2012-07.world.server:target0
192.168.1.15:3260,1 iqn.2012-07.world.server:target0
10.4.0.50:3260,1 iqn.2012-07.world.server:target0
169.254.9.145:3260,1 iqn.2012-07.world.server:target0
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$

---------------------------

#### confirm status after discovery
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ sudo iscsiadm -m node -o show
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$


---------------------------

####  login to target
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ sudo iscsiadm -m node --login
Logging in to [iface: default, target: iqn.2012-07.world.server:target0, portal: 127.0.0.1,3260]
Logging in to [iface: default, target: iqn.2012-07.world.server:target0, portal: 192.168.1.15,3260]
Logging in to [iface: default, target: iqn.2012-07.world.server:target0, portal: 10.4.0.50,3260]
Logging in to [iface: default, target: iqn.2012-07.world.server:target0, portal: 169.254.9.145,3260]
Login to [iface: default, target: iqn.2012-07.world.server:target0, portal: 127.0.0.1,3260]: successful
Login to [iface: default, target: iqn.2012-07.world.server:target0, portal: 192.168.1.15,3260]: successful
Login to [iface: default, target: iqn.2012-07.world.server:target0, portal: 10.4.0.50,3260]: successful
Login to [iface: default, target: iqn.2012-07.world.server:target0, portal: 169.254.9.145,3260]: successful
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$

---------------------------

####  confirm session
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ sudo iscsiadm -m session -o show
tcp: [1] 127.0.0.1:3260,1 iqn.2012-07.world.server:target0
tcp: [2] 192.168.1.15:3260,1 iqn.2012-07.world.server:target0
tcp: [3] 10.4.0.50:3260,1 iqn.2012-07.world.server:target0
tcp: [4] 169.254.9.145:3260,1 iqn.2012-07.world.server:target0
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$


---------------------------

saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$ cat /proc/partitions
major minor  #blocks  name

   7        1    2048000 loop1
   8        0  488386584 sda
   8        1  102400000 sda1
   8        2  102400000 sda2
   8        3  102400000 sda3
   8        4          1 sda4
   8        5  102400000 sda5
   8        6   78781440 sda6
  11        0    1048575 sr0
   8       16  488386584 sdb <== Added new device provided from target
 252        0    1048576 dm-0
   8       32    1048576 sdc
   8       48    1048576 sdd
   8       64    1048576 sde
   8       80    1048576 sdf
saju@saju-desktop:/mnt/iscsi$
saju@saju-desktop:/mnt/iscsi$

---------------------------

No comments:

Post a Comment