SAN Simulation with Openfiler

 Connecting Linux to an iSCSI Target

2013-03-08 10_50_28-Linux1 [Running] - Oracle VM VirtualBox

When it comes to Linux distributions my current first choice is CentOS as it is based on Red Hat Enterprise Linux which is the distro I encounter the most in the businesses and organisations I work with. The big advantage with CentOS is that while it’s almost exactly the same as Red Hat it’s provided free of charge so it’s possible to keep my Linux skills up to speed without the need to pay Red Hat for the privilege.

The installation of CentOS on VirtualBox is incredibly easy (and strikingly similar to the process for Openfiler though the automatic partitioning works on CentOS) so there’s no need to step though it here, though there are some points worth noting before configuring CentOS on VirtualBox to connect to iSCSI targets.

Firstly, do not attempt to get iSCSI working in a CentOS VM without having installed the VirtualBox Guest Additions first. With CentOS there is a need to configure additional Yum repositories so that certain packages needed by the Guest Additions can be installed, but this is a worthwhile step.

Secondly, ensure that all the Linux packages are up to date by running a Yum Update command. The iSCSI initiator is installed by default with the later versions of CentOS but the update will ensure that it and all the associated tools are at the latest versions.

# yum install iscsi-initiator-utils
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base:
* extras:
* rpmforge:
* updates:
base                                                                                                                                  | 3.7 kB     00:00
extras                                                                                                                                | 3.5 kB     00:00
rpmforge                                                                                                                              | 1.9 kB     00:00
updates                                                                                                                               | 3.5 kB     00:00
Setting up Install Process
Package iscsi-initiator-utils- already installed and latest version
Nothing to do

Even though CentOS 6.3 installs the iSCSI initiator software by default, it is advisable to run a yum install (or any other verification technique) just to be sure everything is there and up to date.

# vim /etc/iscsi/iscsid.conf

If the iSCSI target provider (in this case the Openfiler server) has security enabled then it is necessary to set the appropriate passwords and other settings in the iSCSI initiator configuration file located in /etc/iscsi/iscsid.conf. As my test system has no security enabled this step is not necessary here, though in a production environment or any other situation where real data is being stored on an Openfiler system, the configuration of proper security is essential.

# iscsiadm -m discovery -t sendtargets -p
Starting iscsid:                                           [  OK  ],1

Connections to iSCSI targets from Linux systems are created using the iscsiadm command. Here I have requested the list of iSCSI targets this system has access to on the Openfiler server located at IP address A convenient side effect of simply finding an accessible target is that the iSCSI initiator is now configured to connect to that target whenever the system boots.

# /etc/init.d/iscsi restart
Stopping iscsi:                                            [  OK  ]
Starting iscsi:                                            [  OK  ]

A quick restart of the iSCSI service verifies that everything is OK.

# fdisk -l

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00001a94
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        3264    25701376   8e  Linux LVM

Disk /dev/mapper/vg_linux1-lv_root: 22.1 GB, 22087204864 bytes
255 heads, 63 sectors/track, 2685 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg_linux1-lv_swap: 4227 MB, 4227858432 bytes
255 heads, 63 sectors/track, 514 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdb: 39.5 GB, 39460012032 bytes
64 heads, 32 sectors/track, 37632 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Running fdisk reveals that a new storage device is now present (/dev/sdb) and ready to be formatted.

# mkfs.ext3 /dev/sdb
mke2fs 1.41.12 (17-May-2010)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2408448 inodes, 9633792 blocks
481689 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
294 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

I formatted the iSCSI volume with the ext3 file system and accepted all the defaults.

# mkdir /u01
# mount /dev/sdb /u01
# chkconfig iscsi on

 I created a new directory to act as the mount point for the iSCSI volume (I selected /u01 as it’s commonly used with Oracle installations on Linux and shared storage is ideal for use with database systems like Oracle). With the mount point in place, the volume can be mounted. I also set iSCSI to start automatically whenever the Linux server is started.

# vim /etc/fstab
/dev/sdb /u01 ext3 _netdev 0 0wz0r

Finally I edited the fstab file in order to have the iSCSI volume mount automatically when the server is started.

Next –>


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s