添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am trying to mount a NAS using nfs for an application. The Storage team has exported it to the host server and I can access it at /nas/data.

I am using containerized application and this file system export to the host machine will be a security issue as any container running on the host will be able to use the share. So this linux to linux mounting will not work for me.

So the only alternate solution I have is mounting this nas folder during container startup with a username /password.

The below command works fine on a share supporting Unix/Windows. I can mount on container startup

mount -t cifs  -osec=ntlmv2,domain=mydomain,username=svc_account,password=password,noserverino //nsnetworkshare.domain.company/share/folder /opt/testnas

I have been told that we should use nfs option instead of cifs. So just trying to find out whether using nfs or cifs will make any difference.

Specifying nfs option gives below error.

 mount -t nfs -o nfsvers=3,domain=mydomain,username=svc_account,password=password,noserverino //nsnetworkshare.domain.company/share/folder /opt/testnas
mount.nfs: remote share not in 'host:dir' format

Below command doesnt' seem to work either.

 mount -t nfs -o nfsvers=3,domain=mydomain,username=svc_account,password=password,noserverino nsnetworkshare.domain.company:/share/folder /opt/testnas
mount.nfs: an incorrect mount option was specified

I couldn't find a mount -t nfs option example with username /password. So I think we can't use mount -t nfs with credentials.

Please pour in ideas.

Thanks,
Vishnu

CIFS is a file sharing protocol. NFS is a volume sharing protocol. The difference between the two might not initially be obvious.

NFS is essentially a tiny step up from directly sharing /dev/sda1. The client actually receives a naked view of the shared subset of the filesystem, including (at least as of NFSv4) a description of which users can access which files. It is up to the client to actually manage the permissions of which user is allowed to access which files.

CIFS, on the other hand, manages users on the server side, and may provide a per-user view and access of files. In that respect, it is similar to FTP or WebDAV, but with the ability to read/write arbitrary subsets of a file, as well as a couple of other features related to locking.

This may sound like NFS is distinctively inferior to CIFS, but they are actually meant for a different purpose. NFS is most useful for external hard drives connected via Ethernet, and virtual cloud storage. In such cases, it is the intention to share the drive itself with a machine, but simply do it over Ethernet instead of SATA. For that use case, NFS offers greater simplicity and speed. A NAS, as you're using, is actually a perfect example of this. It isn't meant to manage access, it's meant to not be exposed to systems that shouldn't access it, in the first place.

If you absolutely MUST use NFS, there are a couple of ways to secure it. NFSv4 has an optional security model based on Kerberos. Good luck using that. A better option is to not allow direct connection to the NFS service from the host, and instead require going through some secure tunnel, like SSH port forwarding. Then the security comes down to establishing the tunnel. However, either one of those requires cooperation from the host, which would probably not be possible in the case of your NAS.

Mind you, if you're already using CIFS and it's working well, and it's giving you good access control, there's no good reason to switch (although, you'd have to turn the NFS off for security). However, if you have a docker-styled host, it might be worthwhile to play with iptables (or the firewall of your choice) on the docker-host, to prevent the other containers from having access to the NAS in the first place. Rather than delegating security to the NAS, it should be done at the docker-host level.

Well I would say go with CIFS as NFS (Old) few of linux/Unix bistro even stopped support for it.

NFS is the “Network File System” specifically used for Unix and Linux operating systems. It allows files communication transparently between servers and end users machines like desktops & laptops. NFS uses client- server methodology to allow user to view read and write files on a computer system. A user can mount all or a portion of a file system via NFS.

CIFS is abbreviation for “Common Internet File System” used by Windows operating systems for file sharing. CIFS also uses the client-server methodology where A client makes a request of a server program for accessing a file .The server takes the requested action and returns a response. CIFS is a open standard version of the Server Message Block Protocol (SMB) developed and used by Microsoft and it uses the TCP/IP protocol.

If I have a Linux <-> Linux I would choose nfs but if it's a Windows <-> Linux cifs would be the best option.

I have a linux->linux, But as I mentioned, if I mount nas as NFS at host level, then any applications running on the host can use it. Is there any issue using CIFS on a linux->linux. or is that proven that nfs performance is better than cifs? – VVP Dec 4, 2018 at 5:21 It's a more than 2 decades old debate on them. working with linux from several year here what I think I can say in Short Simple & Crispy way; – Prabhat Singh Dec 4, 2018 at 5:53 If your file servers are Windows-based and your clients are mixed, CIFS will tend to provide better performance for your Windows clients than NFS will (Microsoft does some behind-the-scenes tasks that Samba doesn't - IIRC, Intel published a performance study on the performance difference between Windows clients with Windows share-server and Windows clients with Samba share-server). – Prabhat Singh Dec 4, 2018 at 5:54 If your clients are primarily Linux, your more-portable and performant bet is likely to be NFSv4 - either on Linux or Windows 2012+. Note that, to get the more-seamless, cross-platform attribute-propagation, your RHEL clients will need to be running EL7 as the EL6 NFSv4 and IDMAP services are a touch "broken". If using a Windows 2012 NFSv4 server, you'll want everything to be speaking NFS 4.1 (there's various Google-able resources explaining the particulars of "why") – Prabhat Singh Dec 4, 2018 at 5:54

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.