We are Moving

Thank you to everyone who have supported us since our inception. We will be moving to our new site in the coming months. So please check it out at: We will be migrating all the content over, so you don't have to worry about losing anything.

Connecting to storage Systems using iSCSI, NFS, and CIFS (SMB)

As there are a variety of tasks you may need to achieve, there are many different ways to connect to your storage system.  Each operating system has differing methods for utilizing these protocols, and different operating systems will perform differently with each protocol.  For the purpose of this article we are going to focus on two methods of connecting to storage; LUN’s and File Shares.   In my examples I will be using Open Filer as the storage device, then various Linux and Windows editions to connect to the storage system.

In this article I will be covering only the client side of things.  You can see my article on Configuring Open Filer if you wish to quickly setup the server side of any of the protocols I have outlined in this article.  In the future I will post more articles detailing how to create shares without using a pre-packaged solutions like Open Filer.


Logical Unit Numbers (LUN) Explained:

When considering the use of LUN’s there are two main protocols used; Fiber Channel and iSCSI.  

In order to use Fiber Channel you will need a Fiber Channel Host Bus Adapter (HBA) in your Server, and fiber optic cables running to your storage device which must speak the fiber channel protocol.

With iSCSI an HBA is optional and runs over normal Ethernet.  In most cases it is advisable to have a dedicated network port for your iSCSI traffic, but it does not necessarily require any additional hardware.  The reason why you may want to consider adding an iSCSI HBA to the mix is to offload that processing from your servers CPU.

At this point you may ask yourself which will give me better performance, iSCSI or Fiber Channel?  The answer is, I have heard good arguments for each protocol; so it is really up to you.  I usually use iSCSI because it does not require specialized hardware and I get sufficient performance for what I usually use, I will concentrate on iSCSI in this article.

When considering Server Virtualization, both of these protocols are supported on all the server class products, Example: Xenserver, VMWare, and Hyper-V.

Network Shares explained:

There are quite a few protocols for sharing files, in this article I will focus on Network File Systems (NFS) and Server Message Block (SMB) shares.

SMB Shares are also referred to as Common Internet File System (CIFS) shares or Windows Shares. With SMB Shares you specify a resource you want to share on a given server, then the client connects to that resource using something called a Universal Naming Convention (UNC) path.  A UNC path may look something like \\MyServer\ShareName or \\MyServer\Sharename\myfile where MyServer is the name of your server, and Sharename is the name of the resource that has been shared and myfile is the name of the file you wish to access off the network share.  SMB can be used for sharing both files and printers and may use the Netbios Name, DNS Name, or the IP Address of the server.

NFS Shares are primarily used in Unix and Linux based operating systems.  When working with NFS you mount a remote folder to a local path.  For example: if you want to share a folder containing a set of documents with the users are your network, you create something called an NFS Export.  Your client machines then mount this exported share to a path such as /home/username/documents  Then the user can access those documents as if the documents were stored on their machine.

In the context of virtualization, your Virtualization Host server can mount these NFS exports and run virtual machines stored on these NFS Exports.  You will need to check the documentation to verify that the product you use supports NFS.  But at the time of this article VMWare ESX  and Xenserver support  NFS Datastores.   I will cover how that works in a future article.

How to use the Various Protocols:

Now that I have given a basic overview of how some of the more common protocols are used, I would like to give some instructions on how to implement these protocols in your environment.

Attaching to an iSCSI LUN

A server hosting an iSCSI LUN is known as an iSCSI Target.  For a client to connect to the iSCSI Target you need an iSCSI initiator. An iSCSI initiator may be a HBA or some sort of software. Most operating systems do not come with iSCSI initiator software installed.  If you are running windows Vista/Server 2008 or newer this software is already installed. Below are instructions on how to attach to an iSCSI LUN in several Operating Systems:

Windows Vista/7/Server 2008/R2:

  • Click on the Start menu, Select Control Panel
  • Click on Administrative Options
  • Click on iSCSI Initiator
  • You may be prompted to start the iSCSI Initiator Service, Click Yes to start the Service



Most Linux distributions do not come with iSCSI initiator software.  One piece of software which will allow you to connect is the Open-iSCSI Project.  Below is a summary of how to install and configure an iSCSI initiator on Red Hat and Debian based Linux Distributions:

Installing iSCSI Initiator on Red Hat based Distributions:
Open a command prompt and enter: yum install iscsi-initiator-utils

Installing iSCSI Initiator on Debian based Distributions:
Open a command prompt and enter: sudo apt-get install open-iscsi

After you have installed your iSCSI initiator, we have to configure it.  The first step is to enter your authentication information.  This is stored in the /etc/iscsi/iscsid.conf file. Open this file in your favorite text editor.  Assuming your server requires authentication, there are four lines you need to watch for, they are as follows:

node.session.auth.username = My_ISCSI_USR_NAME
node.session.auth.password = MyPassword
discovery.sendtargets.auth.username = My_ISCSI_USR_NAME
discovery.sendtargets.auth.password = MyPassword

In your configuration file you may see a “#” at the beginning of the line.  The lines that start with a “#” are considered comments and are not processed as part of the configuration.  If your server requires authentication, remove the “#” from the beginning of the line, then enter the appropriate information on each line.

node.session.auth.username is used for the iSCSI connection and discovery.sendtargets.auth.username is used for the iSCSI discovery.  In most cases you will enter the same user-name and password for each of these.

Now that your iSCSI authentication is configured, you can start the service by entering the following command:
“/etc/init.d/open-iscsi start”

The iscsiadm utility is used for the last part of the configuration, and that is to tell the initiator where to discover the iSCSI LUN.  You do this by entering the following:
“iscsiadm -m discovery -t sendtargets -p MyServer”
In the above Example, replace MyServer with the machine hosting the iSCSI LUN’s.

You will need to re-start the iSCSI service before the LUN will show up, do this by entering the following:
“/etc/init.d/open-iscsi restart”

*Note*  I have had problems where occasionally the LUN does not show up.  You can attach the LUN by issuing the following command:
“iscsiadm -m node --portal "MyServer:3260" -l”
Where MyServer is the name or ip address of the server hosting the LUN.  The above command will attach all LUN’s advertised to your system on this iSCSI target.

Your LUN should now be attached, you can see it by entering:
“fdisk -l”
You should see output similar to the following:

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1870    15020743+  83  Linux
/dev/sda2            1871        1958      706860    5  Extended
/dev/sda5            1871        1958      706828+  82  Linux swap / Solaris

Disk /dev/sdb: 4529 MB, 4529848320 bytes
140 heads, 62 sectors/track, 1019 cylinders
Units = cylinders of 8680 * 512 = 4444160 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table

The above output is indicating that we need to create a partition on the LUN, good news is our LUN is now showing up.  To create the partition, we can enter:
mkfs.ext3 /dev/sdb
This is of course assuming your LUN showed up as /dev/sdb and you want to partition the entire LUN with one partition.

Next we need to create a folder to mount to, then mount the file system.  We can do that with the following commands
mkdir /mylun
mount /dev/sdb /mylun
you will need to replace /dev/sdb with whatever device your LUN showed up as as and replace mylun with whatever you want to call your LUN.

At this point the LUN is mounted and you can begin using it.  However, next time you restart you will have to re-mount it. To automatically re-mount the LUN every time you restart, you can edit the /etc/fstab file and enter the following:
/dev/sdb /mylun ext3 defaults,auto,_netdev 0 0

If at some point you need to disconnect the LUN for whatever reason, you can unmount the partition using the umount command, Example:
“umount /mylun”

then detach the lun using the following:
“iscsiadm -m node  --portal "MyServer:3260" -u
Where MyServer is the name or ip address of the server hosting the LUN.  The above command will detach all LUNS advertised to your system from this iSCSI target.

If you are permanently detaching the LUN, be sure to edit your fstab file so it will not try to re-mount your file system next time your reboot.

Mounting an NFS Export:

Windows Vista/7/Server 2008/R2:

Before you can connect to an NFS Share you will need to download the latest Subsystem for UNIX-based applications (SUA) from the Microsoft website.  I will post a link on the resources page.

After you have installed the SUA, mounting the NFS Share is fairly easy and much like connecting to a Normal Windows share.  You can mount the share via the Command Prompt by issuing a command such as:
mount //MyServer/MyShare <Drive Letter>

Or you can mount the share via the GUI by:
Click on the Start menu
Right click on Computer, Select Map Network Drive
Select the drive letter you wish to use
Enter MyServer:/MyShare as the path
Replace MyServer with the name of your file server and MyShare with the name of the share.


Most Linux Distributions will come with the necessary software to mount an NFS Share.  However, if you find that you are unable to mount the NFS share, you may need to install the software.

To install the software on a Debian based Distribution (Example: Ubuntu), Type:
apt-get install nfs-common

To install the software on a Red Hat based System (Example: Fedora), Type:
yum install nfs-common

Before you can mount the share, you must create a directory to mount to, first navigate to the mnt directory by typing; “cd /mnt”
Create the mount point by typing “mkdir mymountpoint” where mymountpoint is the name you want to give the mount point.

You can now mount the NFS share by typing the following command:
mount -t nfs MyServer:/MyShare /mnt/mymountpoint

In the above example you would want to replace MyServer with the name of the server hosting the share, MyShare with the name of the share, and mymountpoint with the name of the folder you created in the previous step.

Using the above instructions you will now be able to access the network resource.  However, the resource will not be available after you reboot.  To ensure the NFS Share is automatically mounted after each restart, you need to edit the /etc/fstab file by opening it with a text editor such as vi or gedit and adding the following line:
MyServer:/MyShare /mnt/mymountpoint nfs

In the above example you would want to replace MyServer with the name of the server hosting the share, MyShare with the name of the share, and mymountpoint with the name of the folder you created in the previous step.

Connecting to a SMB/CIFS Share:

Windows Vista/7/Server 2008/R2:

To connect to the share without mapping a drive:
Click Start, Click in the Search Programs and Files field
Enter the UNC Path
Press Enter

To map a drive to the UNC Path:

  • Click on the Start menu
  • Right click on Computer, select Map network Drive
  • From the Drop Down menu, select the drive letter you wish to map to, then enter the UNC path in the text box on the right.  
  • Check the box to reconnect at login (If you want it to reconnect every time you log-in)
  • Click Ok

To Map a UNC path from the command prompt:
Type: net use K: \\myserver\myshare

The above example would map the K: drive and connect it to myshare located on myserver.

You can access the mapped drive the same way you would access any other drive on your machine.  However, keep in mind that the mapped drive is only mapped under your user-name.  If there are users or services running under a different user-name, they will not have access to this resource.  If you have a service which needs to access the network drive you will need to either use a UNC path for that service, or log-in to the computer using the same user-name as the service, map the drive, check the box to re-connect at log-in, then log out of the computer.


Linux does not natively support SMB Shares, you will need to install SMB Client software to access these shares.  Many Distributions now come with SMB clients pre-installed.

If you are running a Debian based Distribution such as Ubuntu:
You can install the SMB Client by using the apt command by entering the following:
apt-get install smbfs smbclient

If you are running a Red Hat based Linux Distribution such as Fedora or Cent OS
You can install the SMB Client by entering the following command:
yum install samba-client

After an SMB client has been installed you must create a mount point to mount the SMB Share.
Navigate to your mnt folder by typing “cd /mnt”
Create a directory by Typing: “mkdir mymountpoint”
Mount the SMB Share at your mount point: “mount -t cifs //myserver/myshare -o username=<yourUsername>,password=<yourPassword> /mnt/mymountpoint”

Unless you want to have to mount this share every time you restart your computer, you will want to modify the fstab file with this information; that way it will automatically get mounted every time your computer starts up.
the fstab file can be found in /etc/fstab
you will need to open the file in a text editor and add the following line:

//myserver/myshare /mnt/mymountpoint cifs auto,user,username=<yourusername>,workgroup=<yourworkgroup>,password= <yourpassword>,uid=500,gid=500,file_mode=0777,dir_mode=0777 ,rw 0 0

Keep in mind the above line has no hard returns, your web browser may be wrapping the text into multiple lines.  The above text should all be on one line in your fstab file.