この記事を作った動機
linux上で、cifsとVPNを使って自分のファイルサーバにアクセスしているのですが、以下のような不満点があり、どうしたらいいか考えてみた結果、いくつか興味深いオプジョンが見つかったので、それを記録しておくだけです。ちなみに、完全な解決とまでは行ってないですが、多少改善が見られた程度って感じです。
- 大きなファイルをやり取りすると、同時に他のファイル操作をしたときにもっさりする
- なにかと、特にvpn環境だと理由不明のファイルマネージャ等のプチフリが多発する
ちょっとしたまとめ
sudo mount -t cifs -o user=username,password="password",gid=1000,uid=1000,vers=3.11,multichannel,max_channels=16,compress //192.168.xxx.xxx/shareName /Path/To/Mount/Point
特に気になったオプション
vers=3.11
smbプロトコルのバージョンを指定する項目で、以下のバージョンが選べる模様です。新しいほどいろんな機能が使えるようです。今回の場合は、使いたい機能が、3.11にあるので、それを指定している前提で、その他気になったオプションをリストアップします。
vers=arg
SMB protocol version. Allowed values are:
• 1.0 - The classic CIFS/SMBv1 protocol.
• 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.
• 3.02 or 3.0.2 - The SMBv3.0.2 protocol that was introduced in Microsoft
Windows 8.1 and Windows Server 2012R2.
• 3.1.1 or 3.11 - The SMBv3.1.1 protocol that was introduced in Microsoft
Windows 10 and Windows Server 2016.
• 3 - The SMBv3.0 protocol version and above.
• default - Tries to negotiate the highest SMB2+ version supported by
both the client and server.
If no dialect is specified on mount vers=default is used. To check Di‐
alect refer to /proc/fs/cifs/DebugData
Note too that while this option governs the protocol version used, not
all features of each version are available.
The default since v4.13.5 is for the client and server to negotiate the
highest possible version greater than or equal to 2.1. In kernels prior
to v4.13, the default was 1.0. For kernels between v4.13 and v4.13.5 the
default is 3.0.
multichannel
manページを読んでいる限り、一つだけでなく複数のデータをやり取りするための、よくわかってないですが、複数のTCPセッション(複数の通信路)みたいなのを開くっぽいです。これを指定して見ると、大きなファイルを操作していても快適にファイルマネージャとか、レスポンスよくいろんなファイル操作が行える傾向にありました。一つだけの通信路では、やはり厳しいものがあるようです。
max_channels=16
multichannelのオプジョンと併用して使う項目です。私は欲張って多ければいいというものでもないと思いますが、とりあえず最大の16にしてみています。こうすると、マウント時にセッション確立に時間がかかるようになるようで、ちょっと遅くなりますが、それ以外においては、特に今のところ問題は感じられていません。
note
以下は、私がman mount.cifs
にあった説明の中で気になった部分を抜き出したものです。
fsc Enable local disk caching using FS-Cache for CIFS. This option could be
useful to improve performance on a slow link, heavily loaded server
and/or network where reading from the disk is faster than reading from
the server (over the network). This could also impact the scalability
positively as the number of calls to the server are reduced. But, be
warned that local caching is not suitable for all workloads, for e.g.,
read-once type workloads. So, you need to consider carefully the situa‐
tion/workload before using this option. Currently, local disk caching is
enabled for CIFS files opened as read-only.
NOTE: This feature is available only in the recent kernels that have been
built with the kernel config option CONFIG_CIFS_FSCACHE. You also need to
have cachefilesd daemon installed and running to make the cache opera‐
tional.
compress
EXPERIMENTAL FEATURE Enables over-the-wire message compression for SMB
3.1.1 or higher mounts. Mount fails when compress is on and vers is set
to a version lower than 3.1.1.
vers=arg
SMB protocol version. Allowed values are:
• 1.0 - The classic CIFS/SMBv1 protocol.
• 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.
• 3.02 or 3.0.2 - The SMBv3.0.2 protocol that was introduced in Microsoft
Windows 8.1 and Windows Server 2012R2.
• 3.1.1 or 3.11 - The SMBv3.1.1 protocol that was introduced in Microsoft
Windows 10 and Windows Server 2016.
• 3 - The SMBv3.0 protocol version and above.
• default - Tries to negotiate the highest SMB2+ version supported by
both the client and server.
If no dialect is specified on mount vers=default is used. To check Di‐
alect refer to /proc/fs/cifs/DebugData
Note too that while this option governs the protocol version used, not
all features of each version are available.
The default since v4.13.5 is for the client and server to negotiate the
highest possible version greater than or equal to 2.1. In kernels prior
to v4.13, the default was 1.0. For kernels between v4.13 and v4.13.5 the
default is 3.0.
--verbose
Print additional debugging information for the mount. Note that this pa‐
rameter must be specified before the -o . For example:
mount -t cifs //server/share /mnt --verbose -o user=username
max_channels=arg
This option is applicable while using multichannel feature. max_channels
option allows the user to specify the number of transport connections
that should be establised between client and server up to a limit of 16.
Using this option implicitly enables the multichannel feature. If
max_channels option not specified, multichannel feature defaults to using
2 connections.
multichannel
This option enables multichannel feature. Multichannel is an SMB3 proto‐
col feature that allows client to establish multiple transport connec‐
tions to an SMB server and bind them into a single authenticated SMB ses‐
sion. This feature enhances fault tolerance and increases throughput by
distributing traffic across several connections. With this mount option
default is to use two channels if the server supports multichannel. The
max_channels parameter can be specified if you desire to use more than
two channels.
echo_interval=n
sets the interval at which echo requests are sent to the server on an
idling connection. This setting also affects the time required for a con‐
nection to an unresponsive server to timeout. Here n is the echo interval
in seconds. The reconnection happens at twice the value of the echo_in‐
terval set for an unresponsive server. If this option is not given then
the default value of 60 seconds is used. The minimum tunable value is 1
second and maximum can go up to 600 seconds.
参考にしたサイトとか
- mount.cifs の man ページ (2025年3月25日)