Network Storage Protocols Discussions

Sharing a CIFS or NFS LUN

Hello guys,

I am new to NAS environment ( NETAPP).

I want to know the procedure of how a LUN can be shared between 2 or more servers through NFS & CIFS. Also, is it possible to specify the server IPs and the users on those IPs who can access that particular shared LUN and if YES then what would be the procedure to do it .


Re: Sharing a CIFS or NFS LUN

you don't share a LUN with cifs or nfs.  LUN is SAN, CIFS/NFS are NAS.  Two completely different things.

LUNs are typically mounted to one server and have the characteristics of an internal hard drive.  so you could mount a LUN to a unix box and then share it out with SaMBa.


i think you really want to do is create a volume, and share it out with both NFS and CIFS.  that you can do.  so just add the volume to your /etc/exports, and then use the cifs shares command and share it out with CIFs.    or use system manager and do it all in the gui.

Re: Sharing a CIFS or NFS LUN

If you want to write to a LUN using a NAS protocol, you must take the LUN offline or unmap it to prevent an iSCSI or FCP host from overwriting data in the LUN. Remember, a LUN cannot be extended or truncated using NFS or CIFS protocols. If you want read access, the LUN can remain online. If you want write access, ensure that the LUN is offline or unmapped. Hit command: " lun share lun_path {none|read|write|all} "


lun share /vol/vol1/qtree1/lun2 read

(The LUN is now readable over NAS).

Re: Sharing a CIFS or NFS LUN

i think you misunderstood that command.  you can NOT access the contents of a LUN via NAS protocols that way.  the LUN share command gives you access to the file that makes up the LUN, not the contents of the LUN.

a LUN must be mounted via a SAN protocol to accessible.

this information is continued here.

a quick search in the docs, or in the community, on the lun share command will help you understand it.

Re: Sharing a CIFS or NFS LUN

I have seen an nfs mount of a volume with a Lun shared. Then a loop back mount to the Lun after the nfs mount. All over nfs. But not sure the point of doing that unless there is no iscsi license.

Re: Sharing a CIFS or NFS LUN

what you are describing is impossible.  you can not mount a LUN with a NAS protocol.

maybe you thought you saw something like that, but you didn't really see it. 

but, if you want to think you saw it.  thats cool.

Re: Sharing a CIFS or NFS LUN

Lofi. Loop back of a mount. Let me find documentation on it. Was really slow but positively remember it. Really was treated as a block device using loopback

Sent from my iPhone 4S

Re: Sharing a CIFS or NFS LUN

Here is an example from CentOS and a 7-Mode VSIM mounting with NFS only (and a loopback to the lun object after).  It is possible, seen in the example below, and I think it is pretty cool.  NFS alone isn't handling it, but the loopback of the block device seen only over NFS without using iSCSI, FC or FCoE.  The application of this would be questionable if someone had iSCSI licensed.  I wouldn't recommend it, but some may have a use for this.  The first example is an iSCSI lun where file1.txt and file2.txt are written, then I cloned the volume to export the clone over NFS only then the loopback mount.

Create and mount a LUN iSCSI from Linux

vsim-7m-1> vol create test aggr2 10g

vsim-7m-1> iscsi start

vsim-7m-1>lun create -s 1g -t linux /vol/test/testlun.lun

[root@localhost~]# /etc/init.d/iscsid start

[root@localhost~]# iscsiadm -m discovery -t sendtargets -p

vsim-7m-1>igroup create -i -t linux linux

vsim-7m-1> lun map /vol/test/testlun.lun linux

vsim-7m-1>lun show

        /vol/test/testlun.lun          1g (1073741824)    (r/w, online, mapped)

vsim-7m-1> igroup show -v

    linux (iSCSI):

        OS Type: linux (logged in on: e0a)

[root@localhost~]# tail -f /var/log/messages

Jun 24
17:39:26 localhost kernel: scsi 4:0:0:0: Direct-Access     NETAPP 
LUN              810a PQ: 0 ANSI:5

Jun 24
17:39:26 localhost kernel: sd 4:0:0:0: Attached scsi generic sg2 type 0

Jun 24
17:39:26 localhost kernel: sd 4:0:0:0: [sdb]
2097152 512-byte logical blocks: (1.07 GB/1.00 GiB)

[root@localhost~]# fdisk /dev/sdb

Command (mfor help): c

DOS Compatibility flag is not set

Command (mfor help): u

Changing display/entry units to sectors

Command (mfor help): n
primary partition          p

Partitionnumber (1-4): 1

[root@localhost~]# mkdir /mnt/iscsi

[root@localhost~]# mkfs /dev/sdb ; mount /dev/sdb /mnt/iscsi

[root@localhost~]# cd /mnt/iscsi

[root@localhost iscsi]# ls -l

total 16

drwx------ 2  root root 16384 Jun 24 17:50 lost+found

[root@localhostiscsi]# > file1.txt

[root@localhostiscsi]# > file2.txt

[root@localhostiscsi]# ls -l

total 16

-rw-r--r-- 1 root root     0 Jun 24 17:51 file1.txt

-rw-r--r-- 1 root root     0 Jun 24 17:51 file2.txt

drwx------ 2 root root 16384 Jun 24 17:50 lost+found

Clone the iSCSI LUN volume and export nfs for loopback mount (no lun mapping)

vsim-7m-1> vol clone create test_clone -b test

vsim-7m-1> lun show

        /vol/test/testlun.lun          1g (1073741824)    (r/w, online, mapped)

        /vol/test_clone/testlun.lun      1g (1073741824)    (r/w, offline)

vsim-7m-1> lun online /vol/test_clone/testlun.lun

vsim-7m-1> lun show

        /vol/test/testlun.lun          1g (1073741824)    (r/w, online, mapped)

        /vol/test_clone/testlun.lun      1g (1073741824)    (r/w, online)

vsim-7m-1> lun share /vol/test_clone/testlun.lun all

vsim-7m-1> exportfs -i -o anon=0 /vol/test_clone

vsim-7m-1> exportfs

/vol/test_clone -sec=sys,rw,anon=0

[root@localhost~]# mount /mnt/nfs

[root@localhost~]# ls -l /mnt/nfs

total 17492

-rw------- 1 root root 1073741824 Jun 24 17:55 testlun.lun

[root@localhost~]# losetup /dev/loop0  /mnt/nfs/testlun.lun

[root@localhost~]# mkdir /mnt/loopback

[root@localhost~]# mount /dev/loop0 /mnt/loopback

[root@localhost ~]# ls -l /mnt/loopback/

total 16

-rw-r--r-- 1 root root     0 Jun 24 17:51 file1.txt

-rw-r--r-- 1 root root     0 Jun 24 17:51 file2.txt

drwx------ 2 root root 16384 Jun 24 17:50  lost+found

Re: Sharing a CIFS or NFS LUN

i will stand corrected.

though i expect whatever crack smoking guy that did that to report for medical help immediately.

that has got to be the slowest block access in the world.

good job though.

Re: Sharing a CIFS or NFS LUN

The use case is limited but the one I remember was for backup (can't remember if mirrored or vaulted to the target controller) without SAN protocol and it gave the ability to get file level backup instead of ndmp of the lun object.  I agree that I wouldn't do it or recommend it though, and when I saw it there was a double and triple take looking at lofiadm running for the backup.

This does differentiate NetApp as a true multi-protocol controller unlike other vendors who claim they are the same, but can't do this.  With gateway devices and several operating systems, using loopback to a lun, or even ndmp of a lun isn't possible on other vendors.  There are some customers who use NDMP for very fast backups of luns with millions of files (although I don't like that either since full every backup, restore is the entire lun and all white space and deleted/nonreclamated space is backed up), but the ability to handle all simultaneously in ONTAP is flexible and unique.

I agree this is off track from the original question though... keep NAS on CIFS/NFS and SAN on FC/FCoE/iSCSI.  Exceptions and edge cases are there for some (with medical advice pending)... anyone using loopback mounts who will admit it and why?