The post you are about to read is a continuation of the post below.
I recommend you read that post as it will help with initial config of the pi
What is Samba?
Samba is a implementation of the Samba Messaging Block (SMB) and the Common Internet File System (CIFS) for Unix systems.
Samba has a lot of uses however the one we will be using today is the file system variant of the program.
Setting up Samba
Firstly you must ssh into your pi
Next you need to install the programs samba and samba-common-bin with the command
sudo apt-get install samba samba-common-bin
Accept all other programs apt tries to install and wait until it has finished installing.
Samba will attempt to start however won’t manage it.
Next you need to plug in a usb hdd and check the mountpoint of the drive with the command
Now you need to create the directory the drive will mount to. For example if you wanted the drive to mount to /media/hdd1 you would need to type
sudo mkdir /media/hdd1
Now you need to tell the raspberry pi where to mount the drive.
You do this by editing /etc/fstab
If you wanted to mount the drive to /media/hdd1 when /dev/sda1 was the mount point and it has an ext4 partition you would type
sudo nano /etc/fstab
and then add the line
/dev/sda1 /media/hdd1 ext4 defaults,noatime 0 1
Then reboot and you should have your hdd mounted to the name you want
Now you should make some directories for your files with mkdir. For example
<sudo mkdir /media/hdd1/Music>
<sudo mkdir /media/hdd1/Movies>
<sudo mkdir /media/hdd1/Documents>
Next you need to edit /etc/samba/smb.conf with the line
sudo nano /etc/samba/smb.conf
Now scroll down until you find the line that reads #security=user and remove the # at the start
Now you need to scroll down to the very bottom and add a new share by typing the text below
comment = R-pi Media shares
path = /media/hdd1
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
read only = no
Press CTRL+X to exit, press Y when asked if you want to keep changes and overwrite the existing configuration file. When back at the console enter the following command to restart the Samba daemons:
sudo /etc/init.d/samba restart
Samba will report that it has restart and now you can create and user who can acsess the shares
I am going to add a user called media with the password pifilms
with the command
sudo useradd media users
sudo passwd media
Passwd will ask for your password twice.
Now you need make media a samba user with the command
sudo smbpasswd -a media
Now all you need to do is connect to the share via osx, linux or windows and then you’re done.
As always thank you for reading. Please tell me if i’ve made any mistakes.