Setup the server
In this part, we will see what I've done in order to setup the server for both client Windows and Ubuntu.
Table of content
Mounted the External Hard disk drive (HDD) 1.1. Study the current list device mount points 1.2. Find the UUID of the device you want to operate on 1.3. Add rules in
/etc/fstab
1.4. Reload mounted devicesSamba 2.1. Installation 2.2. Configuration 2.3. Add users to controls access 2.4. Restart the service 2.5. Encountered errors
Acknowledgements
1. Mounted the External Hard disk drive (HDD)
Note: If you want to sharing a file which is already in the system HDD you can skip this section.
In order to have as much control as possible on the serve, I wanted to choose exactly where my external hard drive will be mounted. By default, it was automatically mounted in the folder /media/<username>
on my raspberry pi. But i wanted to make it automatically mount in /mnt/ext
.
1.1. Study the current list device mount points
You can see where your devices are mounted with the following commands. The last one seams the best overall in term of output controls.
(Note: the following will be based on the output of the last command : findmnt
)
1.2. Find the UUID of the device you want to operate on
Once you have mapped the destionation (TARGET) and the device itself (SOURCE), you can run the command:
This command will give you the UUID of the device you want to control the mounting operation. For example, if you have the following output:
You will know that the device /dev/sda1
have the UUID equals to 38D6-E887
.
1.3. Add rules in /etc/fstab
/etc/fstab
With this UUID, you can add a line in the file /etc/fstab
that takes care of mouting automatically a partition at boot time. To keep the UUID above, we can add the line:
Note: defaults
can be replace by a lot of options. See the aknowledgement section for more information about it.
1.4. Reload mounted devices
Finally, in order to update mounted point with the new /etc/fstab
, you have two choices:
Either you can also run the command
Or you can reboot the system.
2. Samba
In order to managed the windows client, I've installed Samba on my raspberry pi. Samba as nothing in common with the music style except his name. It is a software used in order to share files and printers through a local network (if you want to use it in public network, you will have to use other tool since Samba is a LAN thing, not a WAN thing. See this thread).
I used this software because of my architecture : Samba implements the SMB protocol and provides support for the Windows naming service (WINS) and for joining a Windows Workgroup. So my windows client could also access the share folder.
2.1. Installation
Quick Note: A lot of those steps are prefectly described in the provided links (see Acknowledgements section)
Run the following command in order to install the Samba package
2.2. Configuration
To configure Samba you need to open the file /etc/samba/smb.conf
You can go through the file by yourself. A lot of comments (starting with #
and ;
) are written in order to explain some options you can use.
Basic configuration
Before adding your own section in order to share a folder/a printer, you need to make sure your basic parameters are correct. In the "header" of the file
Special Sections
Note: The file contains two special sections : the Global section, the Homes section and the Printers section.
Global section : Parameters in the [global] section apply to the server as a whole, or are defaults for sections that do not specifically define certain items.
Homes section : If a section called [homes] is included in the configuration file, services connecting clients to their home directories can be created on the fly by the server.
Printers section : This section works like [homes], but for printers.
User Sections
You then have to add your custom space if you want to share it. A basic configuration can be the following :
A few parameters description are given here :
browseable
: bool, This controls whether this share is seen in the list of available shares in a net view and in the browse list.Default: yes.
writeable
(Inverted synonym forread only
) : bool, If this parameter is yes, then users of a service may create or modify files in the service's directory.Default: no
only guest
(synonym ofguest only
) : bool, If this parameter is yes for a service, then only guest connections to the service are permitted. This parameter will have no effect if guest ok is not set for the service.Default: no
public
(synonym ofguest ok
) : bool, if this parameter is yes for a service, then no password is required to connect to the service.Default: no
valid users
: list, This is a list of users that should be allowed to login to this service.Default : # No valid users list (anyone can login)
A details description of all parameters and configurations can be found in the link below (See smb.conf - samba.org in the Acknowledgements section)
Tips
1) If you use a share name (header of the share space) longer than 12 characters, it may not be accessible to some older clients. 2) To make sure your file doesn't contains errors you can run the command below. It will give you a recap of the configuration file your just changed
2.3 Add users to controls access
And then enter bob's password twice. This will create a samba user bob that you can use later in your /etc/samba/smb.conf
file. In the case you forgot your password, you can re-run this command to add the user again to override the previous password.
You can list all the samba users but running the command where -L
stands for list users and -v
stands for verbose :
2.4 Restart the service
Finally run the command in order to make your changes be take into account :
2.5 Encountered errors
[X] Make sure your config file use the same workspace than your client (windows)
by default,
workgroup = WORKGROUP
is enough since it's the basic setup that windows use as workgroup.But it is worth checking if it the same.
[X] Check your iptable rules
Make sure you didn't block the incoming connexion to your raspberry pi !
You can check that if you run those following debug commands :
It should show you if your request was filter or not. It it was filtered, you should check your iptables config (see Acknowledgements section).
or depending on your distribution:
[X] Adding valid users
In order to specify valid users (but also invalid one) you need to create and use UNIX users. You can do it by running the command
```
$ sudo adduser user_name
Enter your password when prompt
$ smbpasswd -a user_name
Use the same password
$ sudo cp /usr/share/samba/smb.conf /etc/samba/smb.conf
$ sudo apt-get install fuse ntfs-3g $ sudo mkdir /mnt/ext # You can create or choose any folder you want. $ sudo mount -t ntfs-3g /dev/sda1 /mnt/ext/ # mount the sda1 on the specified path created earlier.
`` For more information see
NTFS External HDD Read Only File System link` below.
Acknowledgements
Mounting
Mounting and fstab links
Common errors links
Samba
Samba configuration links
Common errors links
Last updated
Was this helpful?