blob: 34b0cf7111f384aff0ea2afc9504b95fd67cd564 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001The CIFS VFS support for Linux supports many advanced network filesystem
2features such as heirarchical dfs like namespace, hardlinks, locking and more.
3It was designed to comply with the SNIA CIFS Technical Reference (which
4supersedes the 1992 X/Open SMB Standard) as well as to perform best practice
5practical interoperability with Windows 2000, Windows XP, Samba and equivalent
6servers.
7
8For questions or bug reports please contact:
9 sfrench@samba.org (sfrench@us.ibm.com)
10
11Build instructions:
12==================
13For Linux 2.4:
141) Get the kernel source (e.g.from http://www.kernel.org)
15and download the cifs vfs source (see the project page
16at http://us1.samba.org/samba/Linux_CIFS_client.html)
17and change directory into the top of the kernel directory
18then patch the kernel (e.g. "patch -p1 < cifs_24.patch")
19to add the cifs vfs to your kernel configure options if
20it has not already been added (e.g. current SuSE and UL
21users do not need to apply the cifs_24.patch since the cifs vfs is
22already in the kernel configure menu) and then
23mkdir linux/fs/cifs and then copy the current cifs vfs files from
24the cifs download to your kernel build directory e.g.
25
26 cp <cifs_download_dir>/fs/cifs/* to <kernel_download_dir>/fs/cifs
27
282) make menuconfig (or make xconfig)
293) select cifs from within the network filesystem choices
304) save and exit
315) make dep
326) make modules (or "make" if CIFS VFS not to be built as a module)
33
34For Linux 2.6:
Adrian Bunkdfc1e142005-05-05 16:15:51 -0700351) Download the kernel (e.g. from http://www.kernel.org)
36and change directory into the top of the kernel directory tree
37(e.g. /usr/src/linux-2.5.73)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382) make menuconfig (or make xconfig)
393) select cifs from within the network filesystem choices
404) save and exit
415) make
42
43
44Installation instructions:
45=========================
46If you have built the CIFS vfs as module (successfully) simply
47type "make modules_install" (or if you prefer, manually copy the file to
48the modules directory e.g. /lib/modules/2.4.10-4GB/kernel/fs/cifs/cifs.o).
49
50If you have built the CIFS vfs into the kernel itself, follow the instructions
51for your distribution on how to install a new kernel (usually you
52would simply type "make install").
53
54If you do not have the utility mount.cifs (in the Samba 3.0 source tree and on
55the CIFS VFS web site) copy it to the same directory in which mount.smbfs and
56similar files reside (usually /sbin). Although the helper software is not
57required, mount.cifs is recommended. Eventually the Samba 3.0 utility program
58"net" may also be helpful since it may someday provide easier mount syntax for
59users who are used to Windows e.g. net use <mount point> <UNC name or cifs URL>
60Note that running the Winbind pam/nss module (logon service) on all of your
61Linux clients is useful in mapping Uids and Gids consistently across the
62domain to the proper network user. The mount.cifs mount helper can be
63trivially built from Samba 3.0 or later source e.g. by executing:
64
65 gcc samba/source/client/mount.cifs.c -o mount.cifs
66
67If cifs is built as a module, then the size and number of network buffers
68and maximum number of simultaneous requests to one server can be configured.
69Changing these from their defaults is not recommended. By executing modinfo
70 modinfo kernel/fs/cifs/cifs.ko
71on kernel/fs/cifs/cifs.ko the list of configuration changes that can be made
72at module initialization time (by running insmod cifs.ko) can be seen.
73
74Allowing User Mounts
75====================
76To permit users to mount and unmount over directories they own is possible
77with the cifs vfs. A way to enable such mounting is to mark the mount.cifs
Steve French099a58f2005-04-28 22:41:07 -070078utility as suid (e.g. "chmod +s /sbin/mount.cifs). To enable users to
Linus Torvalds1da177e2005-04-16 15:20:36 -070079umount shares they mount requires
801) mount.cifs version 1.4 or later
812) an entry for the share in /etc/fstab indicating that a user may
82unmount it e.g.
83//server/usersharename /mnt/username cifs user 0 0
84
85Note that when the mount.cifs utility is run suid (allowing user mounts),
86in order to reduce risks, the "nosuid" mount flag is passed in on mount to
87disallow execution of an suid program mounted on the remote target.
88When mount is executed as root, nosuid is not passed in by default,
89and execution of suid programs on the remote target would be enabled
90by default. This can be changed, as with nfs and other filesystems,
91by simply specifying "nosuid" among the mount options. For user mounts
92though to be able to pass the suid flag to mount requires rebuilding
93mount.cifs with the following flag:
94
95 gcc samba/source/client/mount.cifs.c -DCIFS_ALLOW_USR_SUID -o mount.cifs
96
97There is a corresponding manual page for cifs mounting in the Samba 3.0 and
98later source tree in docs/manpages/mount.cifs.8
99
Steve French099a58f2005-04-28 22:41:07 -0700100Allowing User Unmounts
101======================
102To permit users to ummount directories that they have user mounted (see above),
103the utility umount.cifs may be used. It may be invoked directly, or if
Steve French0cb766a2005-04-28 22:41:11 -0700104umount.cifs is placed in /sbin, umount can invoke the cifs umount helper
Steve French099a58f2005-04-28 22:41:07 -0700105(at least for most versions of the umount utility) for umount of cifs
Steve French0cb766a2005-04-28 22:41:11 -0700106mounts, unless umount is invoked with -i (which will avoid invoking a umount
107helper). As with mount.cifs, to enable user unmounts umount.cifs must be marked
108as suid (e.g. "chmod +s /sbin/umount.cifs") or equivalent (some distributions
109allow adding entries to a file to the /etc/permissions file to achieve the
110equivalent suid effect). For this utility to succeed the target path
111must be a cifs mount, and the uid of the current user must match the uid
112of the user who mounted the resource.
Steve French099a58f2005-04-28 22:41:07 -0700113
114Also note that the customary way of allowing user mounts and unmounts is
115(instead of using mount.cifs and unmount.cifs as suid) to add a line
116to the file /etc/fstab for each //server/share you wish to mount, but
117this can become unwieldy when potential mount targets include many
118or unpredictable UNC names.
119
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120Samba Considerations
121====================
122To get the maximum benefit from the CIFS VFS, we recommend using a server that
123supports the SNIA CIFS Unix Extensions standard (e.g. Samba 2.2.5 or later or
124Samba 3.0) but the CIFS vfs works fine with a wide variety of CIFS servers.
125Note that uid, gid and file permissions will display default values if you do
126not have a server that supports the Unix extensions for CIFS (such as Samba
1272.2.5 or later). To enable the Unix CIFS Extensions in the Samba server, add
128the line:
129
130 unix extensions = yes
131
132to your smb.conf file on the server. Note that the following smb.conf settings
133are also useful (on the Samba server) when the majority of clients are Unix or
134Linux:
135
136 case sensitive = yes
137 delete readonly = yes
138 ea support = yes
139
140Note that server ea support is required for supporting xattrs from the Linux
141cifs client, and that EA support is present in later versions of Samba (e.g.
1423.0.6 and later (also EA support works in all versions of Windows, at least to
143shares on NTFS filesystems). Extended Attribute (xattr) support is an optional
144feature of most Linux filesystems which may require enabling via
145make menuconfig. Client support for extended attributes (user xattr) can be
146disabled on a per-mount basis by specifying "nouser_xattr" on mount.
147
148The CIFS client can get and set POSIX ACLs (getfacl, setfacl) to Samba servers
149version 3.10 and later. Setting POSIX ACLs requires enabling both XATTR and
150then POSIX support in the CIFS configuration options when building the cifs
151module. POSIX ACL support can be disabled on a per mount basic by specifying
152"noacl" on mount.
153
154Some administrators may want to change Samba's smb.conf "map archive" and
155"create mask" parameters from the default. Unless the create mask is changed
156newly created files can end up with an unnecessarily restrictive default mode,
157which may not be what you want, although if the CIFS Unix extensions are
158enabled on the server and client, subsequent setattr calls (e.g. chmod) can
159fix the mode. Note that creating special devices (mknod) remotely
160may require specifying a mkdev function to Samba if you are not using
161Samba 3.0.6 or later. For more information on these see the manual pages
162("man smb.conf") on the Samba server system. Note that the cifs vfs,
163unlike the smbfs vfs, does not read the smb.conf on the client system
164(the few optional settings are passed in on mount via -o parameters instead).
165Note that Samba 2.2.7 or later includes a fix that allows the CIFS VFS to delete
166open files (required for strict POSIX compliance). Windows Servers already
167supported this feature. Samba server does not allow symlinks that refer to files
168outside of the share, so in Samba versions prior to 3.0.6, most symlinks to
169files with absolute paths (ie beginning with slash) such as:
170 ln -s /mnt/foo bar
171would be forbidden. Samba 3.0.6 server or later includes the ability to create
172such symlinks safely by converting unsafe symlinks (ie symlinks to server
173files that are outside of the share) to a samba specific format on the server
174that is ignored by local server applications and non-cifs clients and that will
175not be traversed by the Samba server). This is opaque to the Linux client
176application using the cifs vfs. Absolute symlinks will work to Samba 3.0.5 or
177later, but only for remote clients using the CIFS Unix extensions, and will
178be invisbile to Windows clients and typically will not affect local
179applications running on the same server as Samba.
180
181Use instructions:
182================
183Once the CIFS VFS support is built into the kernel or installed as a module
184(cifs.o), you can use mount syntax like the following to access Samba or Windows
185servers:
186
187 mount -t cifs //9.53.216.11/e$ /mnt -o user=myname,pass=mypassword
188
189Before -o the option -v may be specified to make the mount.cifs
190mount helper display the mount steps more verbosely.
191After -o the following commonly used cifs vfs specific options
192are supported:
193
194 user=<username>
195 pass=<password>
196 domain=<domain name>
197
198Other cifs mount options are described below. Use of TCP names (in addition to
199ip addresses) is available if the mount helper (mount.cifs) is installed. If
200you do not trust the server to which are mounted, or if you do not have
201cifs signing enabled (and the physical network is insecure), consider use
202of the standard mount options "noexec" and "nosuid" to reduce the risk of
203running an altered binary on your local system (downloaded from a hostile server
204or altered by a hostile router).
205
206Although mounting using format corresponding to the CIFS URL specification is
207not possible in mount.cifs yet, it is possible to use an alternate format
208for the server and sharename (which is somewhat similar to NFS style mount
209syntax) instead of the more widely used UNC format (i.e. \\server\share):
210 mount -t cifs tcp_name_of_server:share_name /mnt -o user=myname,pass=mypasswd
211
212When using the mount helper mount.cifs, passwords may be specified via alternate
213mechanisms, instead of specifying it after -o using the normal "pass=" syntax
214on the command line:
2151) By including it in a credential file. Specify credentials=filename as one
216of the mount options. Credential files contain two lines
217 username=someuser
218 password=your_password
2192) By specifying the password in the PASSWD environment variable (similarly
220the user name can be taken from the USER environment variable).
2213) By specifying the password in a file by name via PASSWD_FILE
2224) By specifying the password in a file by file descriptor via PASSWD_FD
223
224If no password is provided, mount.cifs will prompt for password entry
225
226Restrictions
227============
228Servers must support the NTLM SMB dialect (which is the most recent, supported
229by Samba and Windows NT version 4, 2000 and XP and many other SMB/CIFS servers)
230Servers must support either "pure-TCP" (port 445 TCP/IP CIFS connections) or RFC
2311001/1002 support for "Netbios-Over-TCP/IP." Neither of these is likely to be a
232problem as most servers support this. IPv6 support is planned for the future,
233and is almost complete.
234
235Valid filenames differ between Windows and Linux. Windows typically restricts
236filenames which contain certain reserved characters (e.g.the character :
237which is used to delimit the beginning of a stream name by Windows), while
238Linux allows a slightly wider set of valid characters in filenames. Windows
239servers can remap such characters when an explicit mapping is specified in
240the Server's registry. Samba starting with version 3.10 will allow such
241filenames (ie those which contain valid Linux characters, which normally
242would be forbidden for Windows/CIFS semantics) as long as the server is
243configured for Unix Extensions (and the client has not disabled
244/proc/fs/cifs/LinuxExtensionsEnabled).
245
246
247CIFS VFS Mount Options
248======================
249A partial list of the supported mount options follows:
250 user The user name to use when trying to establish
251 the CIFS session.
252 password The user password. If the mount helper is
253 installed, the user will be prompted for password
254 if it is not supplied.
255 ip The ip address of the target server
256 unc The target server Universal Network Name (export) to
257 mount.
258 domain Set the SMB/CIFS workgroup name prepended to the
259 username during CIFS session establishment
260 uid If CIFS Unix extensions are not supported by the server
261 this overrides the default uid for inodes. For mounts to
262 servers which do support the CIFS Unix extensions, such
263 as a properly configured Samba server, the server provides
264 the uid, gid and mode. For servers which do not support
265 the Unix extensions, the default uid (and gid) returned on
266 lookup of existing files is the uid (gid) of the person
267 who executed the mount (root, except when mount.cifs
268 is configured setuid for user mounts) unless the "uid="
269 (gid) mount option is specified. For the uid (gid) of newly
270 created files and directories, ie files created since
271 the last mount of the server share, the expected uid
272 (gid) is cached as as long as the inode remains in
273 memory on the client. Also note that permission
274 checks (authorization checks) on accesses to a file occur
275 at the server, but there are cases in which an administrator
276 may want to restrict at the client as well. For those
277 servers which do not report a uid/gid owner
278 (such as Windows), permissions can also be checked at the
279 client, and a crude form of client side permission checking
280 can be enabled by specifying file_mode and dir_mode on
281 the client
282 gid If CIFS Unix extensions are not supported by the server
283 this overrides the default gid for inodes.
284 file_mode If CIFS Unix extensions are not supported by the server
285 this overrides the default mode for file inodes.
286 dir_mode If CIFS Unix extensions are not supported by the server
287 this overrides the default mode for directory inodes.
288 port attempt to contact the server on this tcp port, before
289 trying the usual ports (port 445, then 139).
290 iocharset Codepage used to convert local path names to and from
291 Unicode. Unicode is used by default for network path
292 names if the server supports it. If iocharset is
293 not specified then the nls_default specified
294 during the local client kernel build will be used.
295 If server does not support Unicode, this parameter is
296 unused.
297 rsize default read size
298 wsize default write size
299 rw mount the network share read-write (note that the
300 server may still consider the share read-only)
301 ro mount network share read-only
302 version used to distinguish different versions of the
303 mount helper utility (not typically needed)
304 sep if first mount option (after the -o), overrides
305 the comma as the separator between the mount
306 parms. e.g.
307 -o user=myname,password=mypassword,domain=mydom
308 could be passed instead with period as the separator by
309 -o sep=.user=myname.password=mypassword.domain=mydom
310 this might be useful when comma is contained within username
311 or password or domain. This option is less important
312 when the cifs mount helper cifs.mount (version 1.1 or later)
313 is used.
314 nosuid Do not allow remote executables with the suid bit
315 program to be executed. This is only meaningful for mounts
316 to servers such as Samba which support the CIFS Unix Extensions.
317 If you do not trust the servers in your network (your mount
318 targets) it is recommended that you specify this option for
319 greater security.
320 exec Permit execution of binaries on the mount.
321 noexec Do not permit execution of binaries on the mount.
322 dev Recognize block devices on the remote mount.
323 nodev Do not recognize devices on the remote mount.
324 suid Allow remote files on this mountpoint with suid enabled to
325 be executed (default for mounts when executed as root,
326 nosuid is default for user mounts).
327 credentials Although ignored by the cifs kernel component, it is used by
328 the mount helper, mount.cifs. When mount.cifs is installed it
329 opens and reads the credential file specified in order
330 to obtain the userid and password arguments which are passed to
331 the cifs vfs.
332 guest Although ignored by the kernel component, the mount.cifs
333 mount helper will not prompt the user for a password
334 if guest is specified on the mount options. If no
335 password is specified a null password will be used.
336 perm Client does permission checks (vfs_permission check of uid
337 and gid of the file against the mode and desired operation),
338 Note that this is in addition to the normal ACL check on the
339 target machine done by the server software.
340 Client permission checking is enabled by default.
341 noperm Client does not do permission checks. This can expose
342 files on this mount to access by other users on the local
343 client system. It is typically only needed when the server
344 supports the CIFS Unix Extensions but the UIDs/GIDs on the
345 client and server system do not match closely enough to allow
346 access by the user doing the mount.
347 Note that this does not affect the normal ACL check on the
348 target machine done by the server software (of the server
349 ACL against the user name provided at mount time).
350 serverino Use servers inode numbers instead of generating automatically
351 incrementing inode numbers on the client. Although this will
352 make it easier to spot hardlinked files (as they will have
353 the same inode numbers) and inode numbers may be persistent,
354 note that the server does not guarantee that the inode numbers
355 are unique if multiple server side mounts are exported under a
356 single share (since inode numbers on the servers might not
357 be unique if multiple filesystems are mounted under the same
358 shared higher level directory). Note that this requires that
359 the server support the CIFS Unix Extensions as other servers
360 do not return a unique IndexNumber on SMB FindFirst (most
361 servers return zero as the IndexNumber). Parameter has no
362 effect to Windows servers and others which do not support the
363 CIFS Unix Extensions.
364 noserverino Client generates inode numbers (rather than using the actual one
365 from the server) by default.
366 setuids If the CIFS Unix extensions are negotiated with the server
367 the client will attempt to set the effective uid and gid of
368 the local process on newly created files, directories, and
369 devices (create, mkdir, mknod).
370 nosetuids The client will not attempt to set the uid and gid on
371 on newly created files, directories, and devices (create,
372 mkdir, mknod) which will result in the server setting the
373 uid and gid to the default (usually the server uid of the
Steve French67594fe2005-05-17 13:04:49 -0500374 user who mounted the share). Letting the server (rather than
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 the client) set the uid and gid is the default. This
376 parameter has no effect if the CIFS Unix Extensions are not
377 negotiated.
378 netbiosname When mounting to servers via port 139, specifies the RFC1001
379 source name to use to represent the client netbios machine
380 name when doing the RFC1001 netbios session initialize.
381 direct Do not do inode data caching on files opened on this mount.
382 This precludes mmaping files on this mount. In some cases
383 with fast networks and little or no caching benefits on the
384 client (e.g. when the application is doing large sequential
385 reads bigger than page size without rereading the same data)
386 this can provide better performance than the default
Steve French67594fe2005-05-17 13:04:49 -0500387 behavior which caches reads (readahead) and writes
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 (writebehind) through the local Linux client pagecache
389 if oplock (caching token) is granted and held. Note that
390 direct allows write operations larger than page size
391 to be sent to the server.
392 acl Allow setfacl and getfacl to manage posix ACLs if server
393 supports them. (default)
394 noacl Do not allow setfacl and getfacl calls on this mount
395 user_xattr Allow getting and setting user xattrs as OS/2 EAs (extended
396 attributes) to the server (default) e.g. via setfattr
397 and getfattr utilities.
398 nouser_xattr Do not allow getfattr/setfattr to get/set xattrs
Steve French737b7582005-04-28 22:41:06 -0700399 mapchars Translate six of the seven reserved characters (not backslash)
400 *?<>|:
Steve French6a0b4822005-04-28 22:41:05 -0700401 to the remap range (above 0xF000), which also
402 allows the CIFS client to recognize files created with
403 such characters by Windows's POSIX emulation. This can
404 also be useful when mounting to most versions of Samba
405 (which also forbids creating and opening files
406 whose names contain any of these seven characters).
407 This has no effect if the server does not support
408 Unicode on the wire.
409 nomapchars Do not translate any of these seven characters (default).
Steve French0cb766a2005-04-28 22:41:11 -0700410 remount remount the share (often used to change from ro to rw mounts
411 or vice versa)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412
413The mount.cifs mount helper also accepts a few mount options before -o
414including:
415
416 -S take password from stdin (equivalent to setting the environment
417 variable "PASSWD_FD=0"
418 -V print mount.cifs version
419 -? display simple usage information
420
421With recent 2.6 kernel versions of modutils, the version of the cifs kernel
422module can be displayed via modinfo.
423
424Misc /proc/fs/cifs Flags and Debug Info
425=======================================
426Informational pseudo-files:
427DebugData Displays information about active CIFS sessions
Steve French09d1db52005-04-28 22:41:08 -0700428 and shares, as well as the cifs.ko version.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429Stats Lists summary resource usage information as well as per
430 share statistics, if CONFIG_CIFS_STATS in enabled
431 in the kernel configuration.
432
433Configuration pseudo-files:
434MultiuserMount If set to one, more than one CIFS session to
435 the same server ip address can be established
436 if more than one uid accesses the same mount
437 point and if the uids user/password mapping
438 information is available. (default is 0)
439PacketSigningEnabled If set to one, cifs packet signing is enabled
440 and will be used if the server requires
441 it. If set to two, cifs packet signing is
442 required even if the server considers packet
443 signing optional. (default 1)
444cifsFYI If set to one, additional debug information is
445 logged to the system error log. (default 0)
446ExtendedSecurity If set to one, SPNEGO session establishment
447 is allowed which enables more advanced
448 secure CIFS session establishment (default 0)
449NTLMV2Enabled If set to one, more secure password hashes
450 are used when the server supports them and
451 when kerberos is not negotiated (default 0)
452traceSMB If set to one, debug information is logged to the
453 system error log with the start of smb requests
454 and responses (default 0)
455LookupCacheEnable If set to one, inode information is kept cached
456 for one second improving performance of lookups
457 (default 1)
458OplockEnabled If set to one, safe distributed caching enabled.
459 (default 1)
460LinuxExtensionsEnabled If set to one then the client will attempt to
461 use the CIFS "UNIX" extensions which are optional
462 protocol enhancements that allow CIFS servers
463 to return accurate UID/GID information as well
464 as support symbolic links. If you use servers
465 such as Samba that support the CIFS Unix
466 extensions but do not want to use symbolic link
467 support and want to map the uid and gid fields
468 to values supplied at mount (rather than the
469 actual values, then set this to zero. (default 1)
470
471These experimental features and tracing can be enabled by changing flags in
472/proc/fs/cifs (after the cifs module has been installed or built into the
473kernel, e.g. insmod cifs). To enable a feature set it to 1 e.g. to enable
474tracing to the kernel message log type:
475
476 echo 1 > /proc/fs/cifs/cifsFYI
477
478and for more extensive tracing including the start of smb requests and responses
479
480 echo 1 > /proc/fs/cifs/traceSMB
481
482Two other experimental features are under development and to test
483require enabling CONFIG_CIFS_EXPERIMENTAL
484
Steve French09d1db52005-04-28 22:41:08 -0700485 More efficient write operations
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486
487 DNOTIFY fcntl: needed for support of directory change
488 notification and perhaps later for file leases)
489
490Per share (per client mount) statistics are available in /proc/fs/cifs/Stats
491if the kernel was configured with cifs statistics enabled. The statistics
492represent the number of successful (ie non-zero return code from the server)
493SMB responses to some of the more common commands (open, delete, mkdir etc.).
494Also recorded is the total bytes read and bytes written to the server for
495that share. Note that due to client caching effects this can be less than the
496number of bytes read and written by the application running on the client.
497The statistics for the number of total SMBs and oplock breaks are different in
498that they represent all for that share, not just those for which the server
499returned success.
500
501Also note that "cat /proc/fs/cifs/DebugData" will display information about
502the active sessions and the shares that are mounted. Note: NTLMv2 enablement
Steve French09d1db52005-04-28 22:41:08 -0700503will not work since its implementation is not quite complete yet. Do not alter
504the ExtendedSecurity configuration value unless you are doing specific testing.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505Enabling extended security works to Windows 2000 Workstations and XP but not to
506Windows 2000 server or Samba since it does not usually send "raw NTLMSSP"
507(instead it sends NTLMSSP encapsulated in SPNEGO/GSSAPI, which support is not
508complete in the CIFS VFS yet).