Distributed File Systems (DFS) are used to easily access multiple CIFS file shares, hosted on separate servers, using a single namespace on your network. The actual shares can either be hosted locally on the DFS server itself or on separate servers.
The benefit of using a single namespace for your users to access your shares is they don’t have to remember the names of each of your file servers; all shares can be accessed through one root name, regardless of where the actual file server resides. The access request will be redirected to the appropriate servers, all without the users’ knowledge.
Another benefit to using DFS, and it’s a major one, is the ability to migrate shared data from one storage platform or server to another, transparently and quickly without your users ever knowing. You simply redirect a DFS hosted share to a new CIFS share, without ever having to change the share’s name.
With standard cifs file servers, you either need to send your users to a new share path after migration or suffer downtime while flipping between the new and old file server hardware, suffering a possible lengthy outage – depending on the complexity of your shares and their permissions.
Before you Begin
This lab will be based on the following configuration.
- One server running CentOS 6.X.
- An Internet connection to access the the CentOS package repository.
Installing and Configuring Samba
- Install Samba.
yum install samba
- Open Samba’s configuration file into a text editor, like VIM or Gedit.
- Under the [global] settings, define the following options, modifying the highlighted values to match your environment.
[global] workgroup = WORKGROUP netbios = MY-DFS-SERVER host msdfs = yes
Understanding the options we are defining:
workgroup The name of your Windows peer-to-peer network. Microsoft’s default is WORKGROUP. netbios This is the single-label computer name used by a Windows on a network. Set this to the name you want your Samba server to have on the network. host msdfs The required parameter which tells Samba to act as a DFS host.
Set Samba Permissions for Selinux
Selinux on CentOS will block connections to Samba shares by default. We’ll need to lift this restriction to allow users to access our DFS and to grant them read/write permissions.
- Allow read and write permission to our samba shares:
setsebool samba_export_all_rw yes
Create the DFS Root Directory
The DFS root directory is where you create your DFS targets – links to other CIFS shares. Targets are created by creating symbolic links to your other cifs shares, using the msdfs protocol. The shares can exist on any server. To keep things simple for this lab, we’ll create a cifs share on the DFS Root which we will create a target for.
- Create the directory that will host the CIFS targets:
mkdir -p /export/dfsroot
- Make sure the DFS root directory is owned by Root.
chown root:root /export/dfsroot
- Secure the DFS root to protect the DFS targets from changes by unauthorized users:
chmod 755 /export/dfsroot
Create a Share to the DFS Root Directory
Next we’ll need to share the DFS root directory to allow our users to access our DFS targets from a single name-space. To do this, we’ll need to open up Samba’s configuration file and add a new share.
- Open Samba’s configuration file in text editor, like VIM:
- Near the bottom of the configuration file, create a Samba share to the DFS root by adding these lines to the bottom of the file, replacing the highlight lines to match your environment:
[dfs] comment = DFS Root Share path = /export/dfsroot browsable = yes msdfs root = yes read only = no
Create a Share to be Used as a DFS Target
The DFS targets are the CIFS shares that a DFS root server will provide access to from a single name-space. These shares can be hosted on the local DFS root server or, ideally, on a separate server. To keep things simple, we’ll create our first share on the DFS root server.
- Prepare a directory to be shared out
mkdir -p /export/samba/finance
- Define the share by opening Samba’s configuration file into a text editor, like VIM:
- Near the bottom of the file, configure you share so it looks similar to the following example:
[finance] path = /export/samba/finance public = yes writable = yes browseable = yes
Add DFS Targets
Finally, it’s time to add some targets to our DFS server. The CIFS shares that we target can be on any host, Linux or Windows. To keep things simple in this tutorial, we’ll create a share on the local DFS host that we’ll use as a DFS target.
- Create a symbolic link to your DFS target.
link -s msdfs:my-dfs-server\finance /export/dfsroot/financeWarning: The symbolic link file for the msdfs share must be lowercase. If it is not, you will get errors when trying to connect to the share.
- Restart the Samba’s daemon to apply our changes
service smb restart