CentOS 7 Installing a Samba Server

Domain name: example.com     Realm name: EXAMPLE.COM

Workgroup: EXAMPLE     Server IP address: xx.xx.xx.xx

Server name: linuxsvr01     Client name: linuxclnt01

Root password: ?Pa55w0rd!

This is a basic configuration of Samba for sharing with Windows. For this to work the Linux host and Windows clients must be in the same domain. Let's check whether Samba is installed

# yum list installed | grep samba
samba.x86_64                      4.2.10-6.el7_2           @updates
samba-client.x86_64               4.2.10-6.el7_2           @updates
samba-client-libs.x86_64          4.2.10-6.el7_2           @updates
samba-common.noarch               4.2.10-6.el7_2           @updates
samba-common-libs.x86_64          4.2.10-6.el7_2           @updates
samba-common-tools.x86_64         4.2.10-6.el7_2           @updates
samba-libs.x86_64                 4.2.10-6.el7_2           @updates

if you don't see the above printout then install them with the following command, it is also possible that you get a partial list, in that case still use use the command below it will only install what's missing and ignore what's already installed

# yum -y install samba samba-client samba-common

We can check (using SSM) if we have any spare physical disks to create a shared volume as follows

# ssm list dev
Device        Free       Used      Total  Pool      Mount point
/dev/sda                        465.76 GB          PARTITIONED
/dev/sda1                       500.00 MB          /boot
/dev/sda   20.00 KB  465.27 GB  465.27 GB centos
/dev/sdb    0.00 KB  931.51 GB  931.51 GB centos
/dev/sdc                        931.51 GB  
/dev/sdd                        931.51 GB
/dev/sde    0.00 KB  931.51 GB  931.51 GB vms01

As I had 4 disks to start with and there are still two left /dev/sdc and /dev/sdd. I am going to use /dev/sdd and with SSM create a logical volume called samba, format it and mount a folder called samba_share. The first command is as follows

# mkdir /mnt/samba_share

Now we can create the logical volume and mount it

# ssm create -s 931.51G -n samba --fstype xfs -p shared /dev/sdd /mnt/samba_share

The samba_share fold needs to have read/write permissions and be available for nobody (in Windows this would be everyone), so we need to issue the following two commands

# chmod -R 777 /mnt/samba_share
# chown -R nobody:nobody /mnt/samba_share

Let us check if the commands have worked

# ls /mnt -l
drwxrwxrwx. 2 nobody nobody 6 Jul  8 12:06 samba_share

The -R with chmod or chown alters file permissions recursively

We are now ready to make the neccesary changes to the smb.conf file, it is good practice to make a copy of the file before making any changes

# cp /etc/samba/smb.conf /etc/samba.conf.bak

Let's open the file (this is a lab situation) and delete everything and add/insert the following

# vi /etc/samba/smb.conf
workgroup = EXAMPLE
server string = Samba Server %v
netbios name = blacklinuxsvr01
security = user
map to guest = bad user
dns proxy = no

path = /mnt/samba_share
browsable = yes
writable = yes
guest ok = yes
dns proxy = no

Save the file and enable and start the smb and nmb services

# systemctl enable smb nmb
# systemctl start smb nmb

Now add Samba to the firewall

# firewall-cmd ––add-service=samba ––permanent ––zone=public
# firewall-cmd ––reload

And allow Samba in SELinux

# chcon -t samba_share_t /mnt/iscsi_share

From Windows open a run prompt and type

\\blacklinuxsvr01\Shares (if it fails try xx.xx.xx.xx\Shares)