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
~$
Best Answer
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:
So just add vers=2.0 or higher to your example and
df
should report the quota correctly: