RHEL5 Xen Guest with a backend NetApp iSCSI device

September 15, 2007

iSCSI was officially ratified by the IETF on 11th of February 2003 and is a transport layer protocol allowing devices to access remote block devices over TCP/IP using the SCSI protocol. Think ISCSI over the network and you have iSCSI.

I will break this tutorial down into 3 parts.

  1. Configure the RHEL5 iSCSI client<br/>
  2. Create an iSCSI LUN on the NetApp filer<br/>
  3. Build the Xen guest<br/>

You will require the following

  • A RHEL5 system
  • A NetApp Filer. The NetApp simulator should suffice.
  • A network between the RHEL5 system and the NetApp device

Lets get started!

Configure the RHEL5 iSCSI client

A device wanting to access a iSCSI device over a TCP/IP network will need an iSCSI driver to act as a iSCSI protocol initiator to transport SCSI requests and responses over a TCP/IP network.

Architecturally, the iSCSI driver combines with the client TCP/IP stack, network drivers, and NICs to provide the same functions as a SCSI adapter driver with an HBA.

Install the iSCSI utility programs on the RHEL5 system.

# yum install iscsi-initiator-utils

You must configure an Initiator Name which the RHEL5 system will use to uniquely identify itself on the network. We will be using the iSCSI Qualified Name (IQN) format for this tutorial, though there also exists another format called IEEE EUI-64 (EUI).

An IQN is defined in the following format

iqn.year-month.domain.unique identifier

iqn: the year naming authority acquired the domain used for the IQN<br/> month: the month naming authority acquired the domain used for the IQN<br/> domain: reversed domain of organizational naming authority<br/> unique identifier: defined by the naming authority<br/>

An example of an IQN i may use would be

iqn.2003-05.com.terdmonk.grimlock

The systems Initiator Name is found within the /etc/iscsi/initiatorname.iscsi which needs to be created and the following added.

InitiatorName=iqn.2003-05.com.terdmonk.grimlock

Please substitute the above example IQN for yours.

Create an iSCSI LUN on the NetApp filer

Connect to your NetApp Filer and create the volume. For this tutorial we will the we are using FlexVols, disk aggregate called ‘aggr01′, the volume name of xen_guest and a size of 5gb.

netapp> vol create xen_guest aggr01 5gb

Create a qtree within the volume so we can store the iSCSI LUN. Ive called the qtree ‘grimlock’ as that would be the name of the system where the iSCSI LUN will be assigned to.

netapp> qtree create /vol/xen_guest/grimlock/

Within the qtree, create a LUN of 5gb with the type of linux.

netapp> lun create -s 5g -t linux /vol/xen_guest/grimlock/lun

Within this tutorial, ive chosen to only use igroups that identify which IQN’s have access to which ISCSI LUN’s that reside on the NetApp filer.

Create the igroup called xen, and a type of linux for the RHEL5 system and map it to the newly created lun.

netapp> igroup create -i -t linux xen iqn.2003-05.com.terdmonk.grimlock
netapp> lun map /vol/xen_guest/grimlock/lun xen

Now that the NetApp Filer is exporting iSCSI LUNs successfully to the network, the RHEL5 system will need to create an iSCSI session.

Firstly, we need to discover the Initiator Name the NetApp Filer is using. This can be done easily with iscsiadm on the RHEL5 system.

# iscsiadm -m discovery -t -p 192.168.1.100

Substitute the IP address used above for the IP address of your NetApp Filer.

The iscsiadm command will return a Initiator Name which may resemble something like

iqn.1992-08.com.netapp:sn.8217231

Once you have the IQN of the target device, you can then start an iSCSI session from the RHEL5 system.

# iscsiadm --mode node --targetname iqn.1992-08.com.netapp:sn.8217231 --portal 192.168.1.100:3260 --login

After successfully logging in, the credentials are stored within the /var/lib/iscsi/nodes/ directory which is used by the iscsi service when started. We only have to run the above iscsiadm commands once which is handy.

If all is well, you should see a new hard disk within your kernel logs.

# dmesg | tail -n 20
scsi6 : iSCSI Initiator over TCP/IP
  Vendor: NETAPP    Model: LUN               Rev: 0.2 
  Type:   Direct-Access                      ANSI SCSI revision: 04
SCSI device sdc: 10485760 512-byte hdwr sectors (5369 MB)
sdc: Write Protect is off
sdc: Mode Sense: bd 00 00 08
SCSI device sdc: drive cache: write through
SCSI device sdc: 10485760 512-byte hdwr sectors (5369 MB)
sdc: Write Protect is off
sdc: Mode Sense: bd 00 00 08
SCSI device sdc: drive cache: write through
 sdc:  unknown partition table
sd 6:0:0:0: Attached scsi disk sdc
sd 6:0:0:0: Attached scsi generic sg2 type 0

Build the Xen guest

Now its time to build the Xen guest using the new iSCSI LUN as the backend storage device which the RHEL5 system will reference as /dev/sdc.

RHEL5 was shipped with a python tool called virt-install which uses libvirt to provision new Xen guests. virt-install takes many command line arguments but also will prompt the user if they do not include required arguments such as the name of the Xen guest.

The virt-install command below uses a kickstart file to define the build specification. I will also be pointing the installation process to a local RHEL5 repository which has been generated by mrepo.

# virt-install --name=megatron \
    --ram=1024 \
    --vcpus=1 \
    --nographics \
    --paravirt \
    --file=/dev/sdc \
    --debug \
    -x "ip=192.168.1.10
    netmask=255.255.255.0
    gateway=192.168.1.1
    dns=192.168.1.2
    ks=http://192.168.1.10/kickstart/megatron" \
    --location=http://192.168.1.10/rhel5-x86_64-install

The relevant lines of the kickstart file that handle the partitioning and formatting are found below

clearpart --all
part /boot --fstype "ext3" --size=100 --asprimary --ondisk=xvda
part pv.2 --size=1 --grow --asprimary --ondisk=xvda
volgroup VolGroup00 pv.2
logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=512 --grow --maxsize=1024

Changelog

2007/09/15 <br/> * Initial release

Previous post:

Next post: