Samba network-filesharing

Samba is an easy way to share an external storage to the whole network.

In my case there is a 2TB USB Hard Disk, which I wanted to share to everyone. My router would provide a built-in NAS option, but not everyone does have the luck of owning a router capable of this option and furthermore, where is the fun in that? Let’s get started:

Pre-Samba:

Install raspberian on the SD. Get the image and a good description of the installation on http://www.raspberrypi.org/

After the installation you can give your Raspberry Pi a shiny name and you can also change the overclocking settings. Mine are running medium overclocking settings.

overclock

If you own a router who is providing DHCP to the network, I suggest giving your raspberry(s) a static IP address. This will make your life easier and also prevents confusion if you are using more then 1 raspberry.

The MAC address might be needed, for this reason use the command:

 

eth0 is your network adapter.

USB drive mount:

First we need to tell your raspberry where to find the USB drive.

 

driver installation

 

You can change “usb” to whatever you like

 

Execute this command AFTER you plug in your USB drive. It should prompt something like “sda:”.

CTRL + C

to cancel the message

Depanding on the filesystem we will mount the USB drive now

FAT32:

 

NTFS

 

exFAT

 

In order to mount the USB drive during every restart we needto do the following steps

 

This will output an UUID. Note your UUID and procceed to the next step

 

Add one of the following at the end of the file (depending on your filesystem)

FAT32

 

NTFS

 

exFAT

 

That’s it, we are done mounting the USB drive. The next step is to install samba:

 

After that we need to edit smb.conf

 

uncomment (delete ‘#’) the following line and save

 

to

 

Now we are adding a samba user to the standard user pi

 

and add the rights to the USB drive

 

we are now editing smb.conf

 

At the end of the file add the following code. change [share] to whatever you want. This will be the name which is displayed to the users.

 

save and restart

 

[1] We are now adding users who may access the USB drive. Replace [user] with a username of your choice.

 

[2] Adding the user to samba. Replace [user] again with the user created in the steop before.

 

We are almost done. The last step is to configure smb.conf:

 

This part now is pretty much customizeable to fit your needs. I will provide a basic configuration and my personal configuration that has 2 users. To add a user simply repeat the steps [1] and [2].

 

This configuration will provide your user full access to your USB drive. Below you can see my setup which is set up for 2 users, one with full rights to the USB drive and another share that has just access to one folder of the USB drive.

smb.conf

Restart your samba one last time.

 

We are done!

Credit goes to http://jankarres.de/ who provides very good guides about Raspberry Pi in German. I have made the whole samba setup using his guides.

 

Leave a Comment