Difference between revisions of "Linux CIFS Utils and Samba"
(→Share a Linux drive with Windows over the network) |
(→Share a Linux drive with Windows over the network) |
||
Line 50: | Line 50: | ||
The question, "how do I do a share a Linux drive with Windows over the network?" is answered with CIFS/SMB. | The question, "how do I do a share a Linux drive with Windows over the network?" is answered with CIFS/SMB. | ||
− | You can use Samba Utils | + | You can use Samba Utils (debian/ubuntu) |
− | + | ||
sudo apt-get install system-config-samba | sudo apt-get install system-config-samba | ||
+ | Or you can manually edit the samba config files | ||
+ | vi /etc/samba/smb.conf | ||
+ | |||
+ | See: [[Example Mythbuntu SMB Shares]] | ||
+ | |||
+ | Restart samba after modifying workgroup and shares | ||
+ | service smbd restart | ||
+ | service nmbd restart | ||
=== resources === | === resources === |
Revision as of 17:52, 11 March 2014
Samba was developed by a team by using "network analysis" or "protocol analysis" to create file and print services to Microsoft Windows clients and servers. Samba is free open source software. Samba makes possible interoperability between Linux/Unix servers and Windows-based clients and servers. Samba originally worked with SMB (Server Message Block) to communicate with Windows machines. Today CIFS (Common Internet File System) is used instead. As a footnote, Samba dates back to 1992!
Server Message Block (SMB) protocol, also called the Session Message Block, NetBIOS or LanManager protocol.
Contents
What are the differences between CIFS and SAMBA?
Today Samba implements the CIFS network protocol to work with changes Microsoft has made in their Windows networking platform. CIFS is the extension of the SMB protocol. The in-kernel CIFS filesystem is generally the preferred method for mounting SMB/CIFS shares on Linux.
The original protocol for sharing files, disks, directories, and printers across a network of Microsoft machines was by use of Server Message Block. There are underlying protocols involved with SMB with some examples being: "NetBIOS over NetBEUI" and "NetBIOS over TCP/IP" Samba traditionally required "NetBIOS over TCP/IP" and didn't support "NetBIOS over NetBEUI." This is fine as NetBEUI is not Internet routable and is not a currently support protocol, even by Microsoft. WINS is for resolving a NetBIOS name to an IP address, however, modern implementations avoid NetBIOS usage though Internal DNS.
CIFS pretty much takes care of all connectivity on a network for your *nix machines and Microsoft Windows. However, Samba does still support SMB and an example where this is useful may be if sharing with older Windows operating systems still using NetBIOS that will want to connect to the Samba server via port 137, 138, 139. The modern CIFS protocol is strictly port 445. This is 'smbfs' versus the modern 'cifs' in Linux.
Microsoft is the industry bully, trying to lay claim to protocols and technologies developed by others. Microsoft tried to claim SMB as their own by calling it Microsoft Networking. The company was a force behind the renaming of SMB (Server Message Block) to CIFS (Common Internet File System.)
The cifs utils Package
The cifs-utils package is available for modern Linux kernels as the protocol is supported directly in the kernel. The cifs-utils package is not part of Samba, although they were originally included with it. Today you do not need to install Samba to have cifs-utils. Install the cifs-utils package for connectivity to Microsoft Networks. Samba is not deprecated. Samba provides both cifs and smb support, and comes with many additional tools. For basic connectivity to a modern Microsoft Windows Network, Samba is simply no longer necessary.
This documentation is largely Linux centric and cifs-utils is a package for Linux systems. Under distributions such as Debian and Ubuntu you can check to see if you have cifs-utils installed and what version it is by typing the command:
apt-cache policy cifs-utils
To install cifs-utils on a modern debian or ubuntu system
apt-get install cifs-utils
To install cifs-utils on an old legacy system
apt-get install smbfs
To install cifs-utils on Redhat / Fedora / CentOS
yum install cifs-utils
Or to install everything, for cifs / smb on RH
yum install samba-client samba-common cifs-utils
You can mount a share with a console command to make a temporary mount until the next reboot, or you can add an entry into fstab to make a persistent mount.
You have to create an empty directory for the mount point. This should be done in /mnt for all mount points you create.
command line mount
Quick basic examples of command line mounts
mount -t cifs -o username=USERNAME,password=PASSWD //192.168.1.88/shares /mnt/share mount -t cifs //192.168.1.102/share_name /media/my_share -o username=theuser,password=thepass,iocharset=utf8,file_mode=0777,dir_mode=0777
fstab persistent mount
Quick basic example of a cfis mount entry in fstab to connect to shares on a Windows file server or NAS device.
fstab example: persistent mounts using exposed credentials
There are more than one ways to do this. This example uses cifs to permanently mount the shares so that they will be available after reboot. If the system complains add the 'noauto' parameter.
- First edit your /etc/hosts file and add the hostname and IP address of the windows share or file server
- Next create mount points in /mnt for each windows share
- Make sure you have cifs installed
- Edit /etc/fstab and add a line for each windows share, see examples:
//apollo/public/ /mnt/public cifs username=nicolep,password=yourpass,iocharset=utf8,sec=ntlm 0 0 //apollo/media/ /mnt/media cifs username=nicolep,password=yourpass,iocharset=utf8,sec=ntlm 0 0 //apollo/video/ /mnt/video cifs username=nicolep,password=yourpass,iocharset=utf8,sec=ntlm 0 0
- mount the shares
mount -a
- This provides read-only access to the network shares.
Example with file permission specified and full rw access
//apollo/public /mnt/public cifs defaults,dir_mode=0777,file_mode=0777,domain=workgroup,username=nicolep,password=yourpass,uid=1000
troubleshooting: devs keep breaking samba
KERNEL CHANGE BREAKS CIFS.
Somewhere between kernel 4.10.0-38 4.15.0-20 a change was made that COULD PREVENT your cifs shares from mounting. Kernels at and before 4.10 used SMB (Server Message Block) version 1.0 as the default if not specified. Most folks did not specify it so it defaulted to 1.0 and worked. Microsoft ditched 1.0 in Windows 10 and dropped support. Linux kernel developers decided to change the kernel code to no longer default to SMB 1.0 and now default to a newer version. For people that are using legacy networks or NAS devices, it breaks the mounting example from above.
Solution: Specify the SMB version.
The solution is to tell mount.cifs to use the SMB2, SMB2.1 or SMB3.0 protocol using the "vers" parameter. in Linux CIFS Utils and Samba Specify 1.0, 2.0, 2.1, or 3.0.
For the following full line example a linux desktop is connecting to an older NAS device. It is necessary to specify SMB version 1.0. Example:
//apollo/video/ /mnt/video cifs defaults,vers=1.0,domain=workgroup,username=nicolep,password=mythtv,iocharset=utf8,sec=ntlm 0 0
FAILED TO CLOSE BROKEN PIPE
Update 2024 Kernel 5.15 Samba 2:4.15.13+dfsg-0ubuntu1.6 -
cp: failed to close 'filename': Broken pipe
A problem with this latest at the time samba Can't copy large files to Windows share - Error closing file: Input/output error issue workaround, specify prior version of cifs on fstab, see example:
//apollo/video/ /mnt/video cifs vers=2.0,defaults,domain=workgroup,username=nicolep,password=yourpass,uid=1000
The question, "how do I do a share a Linux drive with Windows over the network?" is answered with CIFS/SMB.
You can use Samba Utils (debian/ubuntu)
sudo apt-get install system-config-samba
Or you can manually edit the samba config files
vi /etc/samba/smb.conf
See: Example Mythbuntu SMB Shares
Restart samba after modifying workgroup and shares
service smbd restart service nmbd restart
resources
Ubuntu users may wish to read [https://wiki.ubuntu.com/MountWindowsSharesPermanently MountWindowsSharesPermanently] on the Ubuntu Wiki. It is a guide to how to mount CIFS shares permanently.