Connecting Linux to an iSCSI Target
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.
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.
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.
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 192.168.2.10. 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.
A quick restart of the iSCSI service verifies that everything is OK.
Running fdisk reveals that a new storage device is now present (/dev/sdb) and ready to be formatted.
I formatted the iSCSI volume with the ext3 file system and accepted all the defaults.
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.
Finally I edited the fstab file in order to have the iSCSI volume mount automatically when the server is started.