Professional Documents
Culture Documents
1 of 9
http://www.cyberciti.biz/tips/howto-setup-linux-iscsi-target-sanwith-tgt.html
About
Forum
Howtos & FAQs
Low graphics
Shell Scripts
RSS/Feed
Start tgtd
To start the tgtd, enter:
# /usr/sbin/tgtd
Sample output:
05/29/2013 5:53 PM
2 of 9
http://www.cyberciti.biz/tips/howto-setup-linux-iscsi-target-sanwith-tgt.html
Target 1: iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz
System information:
Driver: iscsi
Status: running
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: deadbeaf1:0
SCSI SN: beaf10
Size: 0
Online: No
Poweron/Reset: Yes
Removable media: No
Backing store: No backing store
Account information:
ACL information:
Sample output:
Target 1: iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz
System information:
Driver: iscsi
Status: running
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: deadbeaf1:0
SCSI SN: beaf10
Size: 0
Online: No
Poweron/Reset: Yes
Removable media: No
Backing store: No backing store
LUN: 1
Type: disk
SCSI ID: deadbeaf1:1
SCSI SN: beaf11
Size: 512M
Online: Yes
Poweron/Reset: Yes
Removable media: No
Backing store: /fs.iscsi.disk
Account information:
ACL information:
Sample output:
tcp
tcp6
0
0
0 0.0.0.0:3260
0 :::3260
0.0.0.0:*
:::*
LISTEN
LISTEN
27328/tgtd
27328/tgtd
And you are done. Your system is configured as iSCSI Target. Remote client computer can access this computers hard disk over network. Your can use cluster aware
filesystem to setup real shared storage for small business. Open TCP port 3260 in your firewall, if required.
05/29/2013 5:53 PM
3 of 9
1.
2.
3.
4.
http://www.cyberciti.biz/tips/howto-setup-linux-iscsi-target-sanwith-tgt.html
Following is a quick way to access iSCSI target, under RHEL 5. Let us say your server iSCSI Target IP is 192.168.1.2. Type the following command to discover targets at
a given IP address such as 192.168.1.2 (use 127.0.0.1 if you are testing it from same computer):
# iscsiadm --mode discovery --type sendtargets --portal 192.168.1.2
OR
# iscsiadm --mode discovery --type sendtargets --portal 127.0.0.1
Sample output:
127.0.0.1:3260,1 iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz
OR
# iscsiadm --mode node --targetname iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz --portal 127.0.0.1:3260 --login
Sample output:
Nov
Nov
Nov
Nov
Nov
Nov
Nov
Nov
Nov
Nov
11
11
11
11
11
11
11
11
11
11
07:34:04
07:34:04
07:34:04
07:34:04
07:34:04
07:34:04
07:34:04
07:34:04
07:34:04
07:34:04
vivek-desktop
vivek-desktop
vivek-desktop
vivek-desktop
vivek-desktop
vivek-desktop
vivek-desktop
vivek-desktop
vivek-desktop
vivek-desktop
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
kernel:
[
[
[
[
[
[
[
[
[
[
9039.562312]
9039.572268]
9039.572374]
9039.572530]
9039.572715]
9039.572790]
9039.572940]
9039.572946]
9039.573492]
9039.573593]
sdc is new scsi disk. You may need to restart iSCSI to probe partition and check disks:
# service iscsi restart
# partprobe
# fdisk -l
You can now create parition and mount file system using usual fdisk and mkfs.ext3 commands:
# fdisk /dev/sdc
# mkfs.ext3 /dev/sdc1mkdir /iscsi
# mkdir /iscsi
# mount /dev/sdc1 /iscsi
# df -H
Sample output:
Filesystem
/dev/sda2
tmpfs
varrun
varlock
udev
tmpfs
/dev/sda1
/dev/sda5
/dev/sdb2
/dev/sdc1
Size
99G
1.1G
1.1G
1.1G
1.1G
1.1G
105G
294G
247G
520M
Used
30G
0
361k
0
2.9M
312k
32G
275G
119G
11M
References:
man page tgtadm
tgt project
iSCSI article from the wikipedia
Tweet
0
Like
You should follow me on twitter here or grab rss feed to keep track of new changes.
This blog post is 4 of 4 in the "Linux iSCSI Initiator (SCSI protocol over TCP/IP networks) Tutorial" series. Keep reading the rest of the series:
Table of Contents:
05/29/2013 5:53 PM
4 of 9
1.
2.
3.
4.
http://www.cyberciti.biz/tips/howto-setup-linux-iscsi-target-sanwith-tgt.html
05/29/2013 5:53 PM
5 of 9
http://www.cyberciti.biz/tips/howto-setup-linux-iscsi-target-sanwith-tgt.html
Reply
9 Vincent April 14, 2010 at 4:44 pm
How do you make it persistent after reboot? I am working on ubuntu in my case.
Reply
10 Ade December 23, 2010 at 5:27 pm
I also would like to know the answer to Vincents question how to make it survive a reboot
Great post thanks!
Reply
11 Ade December 23, 2010 at 6:11 pm
Vincent
For making the setup persistent over reboot type this command:
# tgt-admin dump > /etc/tgt/targets.conf
# chkconfig tgtd on
Reply
12 John December 30, 2010 at 9:51 pm
How would you make a boot LUN if all you can set it is LUN 1? Or is there anyway to make it bootable? The only OS Ive been able to boot from that LUN is
SLES 11 SP1. Tried RHEL 5 and Win2k8 and both could not locate the LUN.
Reply
13 Travis Hershberger July 8, 2011 at 6:51 pm
Thanks for a good tutorial. First one I found that was actually helpful in getting everything setup, bookmarked.
Reply
14 Benjamin July 15, 2011 at 11:39 pm
@John
If you are booting Win2k8 from SAN per se, the boot partition has to have a LUN # that is neither 0 or 1 and is not more than 3 digits (ex. LUN 100, 101).
Reply
15 sid August 5, 2011 at 2:25 am
Im on CentOS 5.4 and when i run this command getting below error:
tgtadm lld iscsi op new mode target tid 1 -T iqn.2001-04.com.example:storage.disk2.amiens.sys1.xyz
tgtadm: unrecognized option iscsi
try tgtadm help
can you please help? Thanks
Reply
16 Travis Hershberger August 5, 2011 at 12:09 pm
At first glance it sounds like something isnt correct with the iscsi utilities, Id try reinstalling them.
yum reinstall iscsi-initiator-utils scsi-target-utils
Reply
17 Ethan_ February 21, 2013 at 1:56 am
you should add the sudo command as
sudo tgtadm lld iscsi op new mode target tid 1 -T iqn.2001-04.com.example:storage.disk2.amiens.sys1.xyz
Reply
18 sid August 7, 2011 at 12:50 pm
Thanks for the quick response. I was missing iscsi-initiator-utils. After installing it tgtadm lld iscsi op show mode target started showing results. But is not
persistent after reboot, I did try steps from above comment(# tgt-admin dump > /etc/tgt/targets.conf and # chkconfig tgtd on) and it still doesnt work. Im using
CentOS 5.4. Thanks again for the wonderful post.
05/29/2013 5:53 PM
6 of 9
http://www.cyberciti.biz/tips/howto-setup-linux-iscsi-target-sanwith-tgt.html
Reply
19 sid August 7, 2011 at 1:49 pm
Never mind. I re-did the configuration from scratch and now it is persistent after reboots. Thanks again
Reply
20 rex October 20, 2011 at 5:08 pm
is it possible to do high available cluster environment using this technology??
Reply
21 Travis Hershberger October 20, 2011 at 5:50 pm
It is so long as you remember to use a locking filesystem properly. Something like drbl. Cant say Ive ever set one up so thats all for now.
Reply
22 Soumitra Pal December 4, 2011 at 8:01 am
Its really nice tutorial. I am doing a LAB setup. Where I am using Open Filer for storage. In 2 node RHEL5 systems I need to share the same LUN. using
iscsiadm mode discovery type sendtargets portal 192.168.1.2 I am able to discover the LUN in both of the systems.
Reply
23 Cman February 17, 2012 at 4:06 pm
I have implement one iscsi target . Now wont to implement two iscsi targets with load balancing. is it posible to do so?..
Reply
24 jaja-we February 26, 2012 at 9:19 am
is it is
you nee to use mdadm or LVM mirroring , discover the 2 devices then set up a single device to mount , if you are using a high storage system with ISCSI
capabilites then you can use multipath to bind the 2 devices.
before that you need to make sure the initiator have 2 different IPs (of the same storage ) to talk with.
Reply
25 tmar March 29, 2012 at 11:18 am
Hello,
Is it possible to connect 2 initiators on the same target (initiators and target on centos 6)?, each initiator accessing different block device of the target?
I have tried to configured the /etc/targets.conf using initiator-address ,and also using incominguser password, but it seems these are global variable and can not be
defined per lun. Any ideas?
Reply
26 omkar lagu June 18, 2012 at 5:50 pm
I have a rhel6.1 setup and the below command is not working.. is it a BUG.
/usr/sbin/tgtadm lld iscsi op new mode logicalunit tid 1 lun 1 -b /mnt1/lun10
return code 22
==============================================
tgtadm: invalid request
==============================================
Reply
Leave a Comment
05/29/2013 5:53 PM
7 of 9
http://www.cyberciti.biz/tips/howto-setup-linux-iscsi-target-sanwith-tgt.html
Name *
E-mail *
Website
You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
Security Question:
What is 3 + 2 ?
Solve the simple math so we know that you are a human and not a bot.
Tagged as: bus adapter, iscsi target, linux setup iSCSI Target, san storage, scsi, scsi initiator, server storage, software targets, storage array, target server, target software, tgtadm command, tgtd command
Previous post: Ubuntu Linux: Watch and Play BBC / YouTube Videos With Totem Movie Player
Next post: Install Linux On Intel Xeon 7400 Dunnington
nixCraft
Like
Related Posts
05/29/2013 5:53 PM
8 of 9
http://www.cyberciti.biz/tips/howto-setup-linux-iscsi-target-sanwith-tgt.html
CentOS 4 / Redhat Enterprise Linux 4 iSCSI Installation and Configuration ( iscsi initiators )
Linux: Should You Use Twice the Amount of Ram as Swap Space?
How To Avoid Sudden Outburst Of Backup Shell Script / Program Disk I/O
05/29/2013 5:53 PM
9 of 9
http://www.cyberciti.biz/tips/howto-setup-linux-iscsi-target-sanwith-tgt.html
2004-2013 nixCraft. All rights reserved. Cannot be reproduced without written permission.
Privacy Policy | Terms of Service | Questions or Comments | Copyright Info | Sitemap
05/29/2013 5:53 PM