ali*_*i_m 6 linux samba mount cifs ubuntu
我有几个 Linux 客户端在运行 Windows Server 2012 的远程计算机上安装共享。相关行/etc/fstab如下所示:
//server.address.com/share /media/share cifs rw,user,noauto,_netdev,soft,cred=/etc/samba/cred/share 0 0
Run Code Online (Sandbox Code Playgroud)
如果我df用来查询可用空间量,我会得到:
~$ 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
Run Code Online (Sandbox Code Playgroud)
我使用以下方法获得基本相同的使用情况统计信息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
Run Code Online (Sandbox Code Playgroud)
这里,4096 * 210294051 / 2^30 = 802.2GB 免费。但是我知道共享几乎完全填满的事实 - 从 Windows 客户端我看到使用了 1.79/1.80T。
我怀疑差异可能与此问题有关。根据该讨论线程(始于 2012 年),CIFS 内核客户端不支持报告配额使用情况。我没有遇到任何关于该主题的更新信息(我的客户运行 Ubuntu 14.04、内核 v3.13.0-46-generic、mount.cifs v6.0)。
我试过用nounix标志挂载,但我仍然得到不正确的使用统计信息:
~$ 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
Run Code Online (Sandbox Code Playgroud)
我也尝试过使用quota,但这大概只适用于 NFS 挂载,因为它不会为我的 CIFS 共享打印任何内容:
~$ quota -v
~$
Run Code Online (Sandbox Code Playgroud)
小智 2
如果您没有指定 SMB 协议版本的安装选项,它将使用默认值,即 1.0。仅 SMB 协议版本 2.0 及更高版本支持报告配额。fstab 中的 SMB 版本指定如下:
\n\nman mount.cifs\n...\nOPTIONS \n...\n\n vers=\n SMB protocol version. Allowed values are:\n\n \xc2\xb7 1.0 - The classic CIFS/SMBv1 protocol. This is the default.\n\n \xc2\xb7 2.0 - The SMBv2.002 protocol. This was initially introduced in Windows Vista Service Pack 1, and Windows Server 2008.\n Note that the initial release version of Windows Vista spoke a slightly different dialect (2.000) that is not\n supported.\n\n \xc2\xb7 2.1 - The SMBv2.1 protocol that was introduced in Microsoft Windows 7 and Windows Server 2008R2.\n\n \xc2\xb7 3.0 - The SMBv3.0 protocol that was introduced in Microsoft Windows 8 and Windows Server 2012.\n\n Note too that while this option governs the protocol version used, not all features of each version are available.\nRun Code Online (Sandbox Code Playgroud)\n\n因此,只需将 vers=2.0 或更高版本添加到您的示例中,并且df应该正确报告配额:
//server.address.com/share /media/share cifs rw,user,noauto,_netdev,soft,cred=/etc/samba/cred/share,vers=2.0 0 0\nRun Code Online (Sandbox Code Playgroud)\n