Using Oracle Linux iSCSI targets with Oracle VM

A few days ago I had written a blog entry on how to use Oracle Solaris 10 (in my case), ZFS and the iSCSI target feature in Oracle Solaris to create a set of devices exported to my Oracle VM server.

Oracle Linux can do this as well and I wanted to make sure I also tried out how to do this on Oracle Linux and here are the results.

When you install Oracle Linux 5 update 5 (anything newer than update 3), it comes with an rpm called scsi-target-utils. To begin your quest, should you choose to accept it :) make sure this is installed. rpm -qa |grep scsi-target

If it is not installed : up2date scsi-target-utils

The target utils come with a tool tgtadm which is similar to iscsitadm on Oracle Solaris.

There are 2 components again on the iSCSI server side. (1) create volumes - we will use lvm with lvcreate (2) expose a target using tgtadm.

My server has a simple setup. All the disks are part of a single volume group called vgroot.

To export a 50Gb volume I just create a new volume : lvcreate -L 50G -nmytest1 vgroot

This will show up as a new volume in /dev/mapper as /dev/mapper/vgroot-mytest1. Create as many as you want for your environment. Since I already have my blog entry about the 5 volumes, I am not going to repeat the whole thing. You can just go look at the previous blog entry.

Now that we have created the volume, we need to use tgtadm to set it up :

make sure the service is running : /etc/init.d/tgtd start or service tgtd start
(if you want to keep it running you can do chkconfig tgtd on to start it automatically at boottime)

Next you need a targetname to set everything up. My recommendation would be to install iscsi-initiator-utils . This will create an iscsi id and put it in /etc/iscsi/initiatorname.iscsi.

For convenience you can do :
source /etc/iscsi/initiatorname.iscsi
echo $InitiatorName

and from here on use $InitiatorName instead of the long complex iqn.

create your target :

tgtadm --lld iscsi --op new --mode target --tid 1 -T $InitiatorName

to show the status :

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

add the volume previously created :

tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/mapper/vgroot-mytest1

re-run status to see it's there :

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

and just like on Oracle Solaris you now have to export (bind) it :

tgtadm --lld iscsi --op bind --mode target --tid 1 -I

If you want to export the lun to every iscsi initiator then replace the iqn with ALL. Of course you have to add the iqn of each iscsi initiator or client you want to connect. In the case of my 2 node Oracle VM server setup, both Oracle VM server's initiator names would have to be added.

use status again to see that it has this iqn under ACL

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

You can drop the --lld iscsi if you want, or alias it. It just makes the command line more obvious as to what you are doing.

Oracle VM side :

Refer back to the previous blog entry for the detailed setup of my Oracle VM server volumes but the exact same commands will be used there.

discover : iscsiadm --mode discovery --type sendtargets --portal
login : iscsiadm --mode node --targetname iscsi targetname --portal --login
get devices : /etc/init.d/iscsi restart

and voila you should be in business.

have fun.


Wim, In our environment, we use multiple iSCSI interfaces on the same network connecting to an EqualLogic. What I have tried doing multiple times, and have not had success doing, is to use `iscsiadm -m iface` to setup an iface device on my ovm servers so that I can have two eth's -- eth2 and eth3, for example -- that can each create an iSCSI session down it. It works fine to just connect my iSCSI targets to the ifaces and have multiple devices show up that are then managed by dm-multipath. However, what I'd like to have is eth2 connecting to a bridge device called iSCS0 and eth3 connecting to bridge iSCSI1. That way, I can setup an iSCSI0:1 and iSCSI1:0 as interfaces on my ovm server to allow it to connect to my EqualLogic storage. And then my vm's could also use software initiation from within the vm. This would at least give us flexibility if we ever wanted to start doing it that way. Currently, in order to get iSCSI devices to my guests, I need to use "Shared Virtual Disks" and pass it through to the vm. ALthough that may be more secure, it isn't as flexibile. I was wondering if you've dealt with something like this? Tom Lisjac said that he had successfully done this before. I attempted in a physical environment as well as in a VirtualBox environment and can't seem to get it to work. It might all be moot once OVM 3 is a go though... so I'm not sure how much effort I want to put into testing it...

Posted by Joe Hoot on January 09, 2011 at 12:32 AM PST #

I haven't yet but I will try :)

Posted by wim.coekaerts on January 09, 2011 at 02:04 AM PST #

Any help would be greatly appreciated!

For some reason, Oracle VM Manager only sees 1 iSCSI initiator. I have another NIC card on my SAN segment that I would like to connect to my Equallogic. I was told that that I should do "everything" from the Oracle VM Manager but I just cannot find a way in order for it to associate an initiator name with my other NIC card connected to the SAN segment. Thanks!

Posted by Adam on June 15, 2012 at 11:47 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Wim Coekaerts is the Senior Vice President of Linux and Virtualization Engineering for Oracle. He is responsible for Oracle's complete desktop to data center virtualization product line and the Oracle Linux support program.

You can follow him on Twitter at @wimcoekaerts


« July 2016