6

I have several Linux clients that mount a share on a remote machine running Windows Server 2012. The relevant line in /etc/fstab looks like this:

//server.address.com/share /media/share cifs rw,user,noauto,_netdev,soft,cred=/etc/samba/cred/share 0 0

If I use df to query the amount of free space, I get:

~$ df -kh /media/share
Filesystem                 Type  Size  Used Avail Use% Mounted on
//server.address.com/share cifs  1.8T  1.1T  803G  57% /media/share

I get basically the same usage statistics using stat -f:

~$ stat -f /media/share
  File: "/media/share"
    ID: 0        Namelen: 4096    Type: cifs
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 483183820  Free: 210294051  Available: 210294051
Inodes: Total: 0          Free: 0

Here, 4096 * 210294051 / 2^30 = 802.2GB free. However I know for a fact that the share is almost completely filled - from a Windows client I see that 1.79/1.80T is used.

I suspect that the discrepancy may be related to this issue. According to that discussion thread (started in 2012), the CIFS kernel client does not support reporting quota usage. I haven't come across any newer information on the subject (my clients run Ubuntu 14.04, kernel v3.13.0-46-generic, mount.cifs v6.0).

I have tried mounting with the nounix flag, but I still get incorrect usage stats:

~$ df -kh /media/share
Filesystem                 Type  Size  Used Avail Use% Mounted on
//server.address.com/share cifs  1.8T  1.1T  803G  57% /media/share

~$ stat -f /media/share
  File: "/media/share"
    ID: 0        Namelen: 4096    Type: cifs
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 483183820  Free: 210294040  Available: 210294040
Inodes: Total: 0          Free: 0

I have also tried using quota, but this presumably only works for NFS mounts, since it prints nothing for my CIFS share:

~$ quota -v
~$
2

If you don't specify a mount option for the version of the SMB protocol, it uses the default, which is 1.0. Reporting the quota is only supported by SMB protocol version 2.0 and higher. SMB Version in fstab is specified like:

man mount.cifs
...
OPTIONS 
...

     vers=
           SMB protocol version. Allowed values are:

           ·   1.0 - The classic CIFS/SMBv1 protocol. This is the default.

           ·   2.0 - The SMBv2.002 protocol. This was initially introduced in Windows Vista Service Pack 1, and Windows Server 2008.
               Note that the initial release version of Windows Vista spoke a slightly different dialect (2.000) that is not
               supported.

           ·   2.1 - The SMBv2.1 protocol that was introduced in Microsoft Windows 7 and Windows Server 2008R2.

           ·   3.0 - The SMBv3.0 protocol that was introduced in Microsoft Windows 8 and Windows Server 2012.

           Note too that while this option governs the protocol version used, not all features of each version are available.

So just add vers=2.0 or higher to your example and df should report the quota correctly:

//server.address.com/share /media/share cifs rw,user,noauto,_netdev,soft,cred=/etc/samba/cred/share,vers=2.0 0 0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.