Mounting iSCSI LUNs via Ubuntu

One of the challenges we faced during the recovery of our QNAP Data was the ability to mount the “rescued” LUN files and access their data. The system to do this is an Ubuntu 13.04 environment with open-iscsi and iscsitarget installed – the exact definition of the components I used have been published earlier.

Removing a LUN from the iSCSI Enterprise Targets

If a LUN is advertised as iSCSI Enterprise Target and has been accessed for the data required, it can be removed from the target list. To do this, open a Terminal Window and switch to superuser privileges.

sudo su

First of all, we need to stop the running iSCSI Target Service

service iscsitarget stop

Then we can remove the Target definition from /etc/iet/ietd.conf – “iet” stands for “iSCSI Enterprise Target”, “ietd” logically means “iSCSI Enterprise Target Definition”.

nano /etc/iet/ietd.conf

Locate the LUN you want to disable and comment out its definition (better than deleting it, that way you retain a documentation of how things are done). Then save the file and exit. If you need to restart the iscsitarget service for other LUNs, just issue the following command.

service iscsitarget start

Keep in mind that – if the LUN is still mounted – you will have to (or at least should) unmount it first!

Adding a new LUN as iSCSI Enterprise Target

Edit the /etc/iet/ietd.conf file to add a new iSCSI Target LUN. The format is

Target [iSCSI Qualified Name]
     Lun 0 Path=[Path to LUN]

For example

Target iqn.2014-01.private:myLUN
     Lun 0 Path=/media/azapf/.../myLun.000

Then restart the iSCSI Service

service iscsitarget restart

The service should now restart – you are not going to see much yet but you can check for any errors that may have occurred (e.g. inaccessible LUN Files, etc.) by using the command

dmesg

iSCSI LUN Discovery and Mounting

Once the iSCSI Target is defined and published, you need to discover and mount the new LUN. The tool to work with is iscsiadm – a component of open-iscsi.

The discovery tells you all “published” LUNs of a given server (portal):

iscsiadm --mode discovery --type sendtargets --portal 127.0.0.1

Working on the local TCP Lookback, this will provide a list of all locally defined iSCSI Targets. It will provide an output similar to this:

127.0.0.1:3260,1 iqn.2014-01.private:myLUN

for the LUN defined above. This is the line you need to copy (or retype) for accessing the LUN:

iscsiadm --mode node --target iqn.2014-01.private:myLUN --portal 127.0.0.1 --login

You should receive a message saying “Login to iqn.2014-01.private:myLUN successful.”

Using either the dmesg command or fdisk -l you can find the device name given to the connectd LUN. In my case, it is /dev/sdd. With this information, you can now mount the connected LUN.

mount /dev/sdd1 /mnt/LUN

In my case, however, the file system is not any of the standard Linux file systems but a VMWare Datastore so mounting is done differently (and you need to have vmfs-tools installed!)

vmfs-fuse /dev/sdd1 /mnt/LUN

That should do the job and mount the LUN…

This entry was posted in Linux, Ubuntu. Bookmark the permalink.

Leave a Reply

Your email address will not be published.