NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.
Forum Discussion
Jinder
Feb 27, 2013Aspirant
Mounting CIFS share on Ubuntu
Hi I had to rebuild my ubuntu box and previously I was using fstab for mounting my NAS CIFS enabled shares. My fstab looks like this: //192.168.1.65/Documents /home/jinder/Documents cifs creden...
SurplusGadgets
Mar 24, 2013Aspirant
Hope this little tutorial helps. Confusing but key to remember is there are a minimum of four different user accounts to keep straight when analyzing the connection of a Ubuntu Linux box to a ReadyNAS via the CIFS protocol:
[1] The account/group a user is logged into your Ubuntu Linux box with when trying to access the mounted share,
[2] The account/group used by the Ubuntu kernel to interact with the mounted ReadyNAS share,
[3] The account(/group) used by the Ubuntu kernel to connect with the ReadyNAS box, and finally
[4] The account/group setup on your ReadyNAS share that owns the share and sets permissions of objects created in it.
You setup the Ubuntu kernel with the mount.cifs command (or /etc/fstab settings).
The username/password supplied to the Ubuntu mount.cifs command is #3 above: a username/password account on the ReadyNAS to connect or login with.
The UID, GID and Masks supplied to the Ubuntu mount.cifs command are #2 above and from accounts on the Ubuntu machine side.
So use a ReadyNAS account for #3 that will have the appropriate access to the ReadyNAS share as setup on the ReadyNAS under the CIFS setup (#4). Does not need to be the owner (#4) but likely must have the Unix Group access you want.
If you forgo the UID/GID/Mask in the mount.cifs command, you simply see ReadyNAS Linux internal ID's and masks on the Ubuntu side. Similarly, the ReadyNAS Share uses #3 to determine if access is allowed and then #4 to actually manipulate changes to the share. The values used on the Ubuntu box (#1, #2) are ignored.
For me, I use common groups and group RWX access when setting up accounts #1 and #2. And then common groups with group RWX when setting up accounts #3 and #4. You can make #3 default to #1 on Ubuntu by dropping settings in the mount.cifs command, but then you have to replicate the passwd/shadow files on each Ubuntu box on the ReadyNAS (including same ID's).
All this complication comes from the fact that one is using a Windows protocol (CIFS/SMB) to communicate between two Linux systems. ReadyNAS, even in their CIFS setup, is exporting their Linux internal implementation (of owners, groups, and world access; RWX; etc.). Windows and CIFS/SMB uses Users, Domains, and ACL lists.
Am currently struggling to set things up simplest and least error prone myself. Have not dropped back to a setup of CIFS exclusively for Windows, NFS exclusively for Linux, and only streaming protocols for the Android devices -- as this still requires keeping common accounts kept up to date. Have not found a nice tutorial on how to do a setup close to what I want yet either ...
Oh, and I have a 16TB Ultra4+ and 8TB NV4+. The former gotten after discovering no more firmware upgrades to allow expansion of the NV+ :( But key is there are multiple ReadyNAS to keep up to date with account settings as well.
A few final things that I learned the hard way. Use settings in your /etc/fstab entries of noauto, users, and _netdev. You can get into issues when the Ubuntu box boots otherwise. And remember /etc/fstab is visible to everyone. So if you want the #2 account password hidden, use a "credentials" setting with a file that is protected from all but root. (But then you cannot allow a user to auto-mount and dismount shares easily either.) Still fine tuning ....
Here is an example of my /etc/fstab entries:
[1] The account/group a user is logged into your Ubuntu Linux box with when trying to access the mounted share,
[2] The account/group used by the Ubuntu kernel to interact with the mounted ReadyNAS share,
[3] The account(/group) used by the Ubuntu kernel to connect with the ReadyNAS box, and finally
[4] The account/group setup on your ReadyNAS share that owns the share and sets permissions of objects created in it.
You setup the Ubuntu kernel with the mount.cifs command (or /etc/fstab settings).
The username/password supplied to the Ubuntu mount.cifs command is #3 above: a username/password account on the ReadyNAS to connect or login with.
The UID, GID and Masks supplied to the Ubuntu mount.cifs command are #2 above and from accounts on the Ubuntu machine side.
So use a ReadyNAS account for #3 that will have the appropriate access to the ReadyNAS share as setup on the ReadyNAS under the CIFS setup (#4). Does not need to be the owner (#4) but likely must have the Unix Group access you want.
If you forgo the UID/GID/Mask in the mount.cifs command, you simply see ReadyNAS Linux internal ID's and masks on the Ubuntu side. Similarly, the ReadyNAS Share uses #3 to determine if access is allowed and then #4 to actually manipulate changes to the share. The values used on the Ubuntu box (#1, #2) are ignored.
For me, I use common groups and group RWX access when setting up accounts #1 and #2. And then common groups with group RWX when setting up accounts #3 and #4. You can make #3 default to #1 on Ubuntu by dropping settings in the mount.cifs command, but then you have to replicate the passwd/shadow files on each Ubuntu box on the ReadyNAS (including same ID's).
All this complication comes from the fact that one is using a Windows protocol (CIFS/SMB) to communicate between two Linux systems. ReadyNAS, even in their CIFS setup, is exporting their Linux internal implementation (of owners, groups, and world access; RWX; etc.). Windows and CIFS/SMB uses Users, Domains, and ACL lists.
Am currently struggling to set things up simplest and least error prone myself. Have not dropped back to a setup of CIFS exclusively for Windows, NFS exclusively for Linux, and only streaming protocols for the Android devices -- as this still requires keeping common accounts kept up to date. Have not found a nice tutorial on how to do a setup close to what I want yet either ...
Oh, and I have a 16TB Ultra4+ and 8TB NV4+. The former gotten after discovering no more firmware upgrades to allow expansion of the NV+ :( But key is there are multiple ReadyNAS to keep up to date with account settings as well.
A few final things that I learned the hard way. Use settings in your /etc/fstab entries of noauto, users, and _netdev. You can get into issues when the Ubuntu box boots otherwise. And remember /etc/fstab is visible to everyone. So if you want the #2 account password hidden, use a "credentials" setting with a file that is protected from all but root. (But then you cannot allow a user to auto-mount and dismount shares easily either.) Still fine tuning ....
Here is an example of my /etc/fstab entries:
//MediaServer.local/MoviesMP4 /media/MoviesMP4 cifs noauto,users,_netdev,credentials=/root/.smbcredentials,iocharset=utf8,uid=randy,gid=users,file_mode=0774,dir_mode=0775 0 0
Related Content
NETGEAR Academy
Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology!
Join Us!