In this tutorial we will learn how to install and configure the Samba file server. The Orange Pi – or any other mini-PC in the Raspberry Pi family – can do almost as much as a Windows PC or Mac but you often need to share files with others Computers (or mini PCs) on its local network. Unfortunately, either on Raspbian or Armbian, nothing is installed by default. Fortunately, in the Linux world, there is always an open source solution for all needs. This tutorial applies to both Raspberry Pi and Orange Pi, with or without graphical interface (server version).
Install Samba under Armbian or Raspbian
Samba is a proprietary protocol (SMB / CIFS) developed by Microsoft. It’s a cross-platform project. It allows file exchange and network sharing. It works on Linux, Windows and MacOS. To install it, open a Terminal and run the following command
apt-get install libcups2 samba samba-common cups
This command installs Samba and Cups for printer sharing. If you do not need printer sharing, simply run
sudo apt-get install samba
Configuring Samba
Before changing the configuration, let’s first make a backup copy of the file
smb.conf
sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
Create a new configuration file
sudo nano /etc/samba/smb.conf
Paste this configuration into the file and replace the name of the workgroup – here WORGROUP – by yours.
[global] workgroup = WORKGROUP server string = Samba Server %v netbios name = orangepi security = user board to guest = bad user dns proxy = no
The name defined by the netbios parameter will be displayed in the file manager under Windows and the Finder under macOS.
If you do not know the name of the workgroup, open the command prompt under Windows (or powershell) and run the following command
net config workstation
Save the configuration file – CTRL + X then Y – then restart the samba service
sudo systemctl restart smbd.service
Allow users to access the share folder
It is possible to allow any user to access the shared folder. Here, I suggest you keep control of your mini PC and allow only users declared on the system.
Samba is able to use the users already present on the system. However, you must create a password that is dedicated to samba. Consider for example the user pi (by default, nothing prevents you to create a pi user on Armbian at the installation), run the following command to set the Samba password
pi@orangepiplus2e:~$ sudo smbpasswd -a pi New SMB password: Retype new SMB password:
You can re-enter your password or create a new one. Run this command again to change the Samba password. The advantage is not to multiply the users on your environment.
Add Sharing Folders
You can share existing folders. For security, it is best to control access to shared folders. To do this, we will create a new share folder where you can add other directories. Each directory has these access rights. The location of the file is not important. Here we will create the shared folder directly on the desktop.
mkdir -p /home/pi/Desktop/Share
Now we will add these folders to the configuration file
sudo nano /etc/samba/smb.conf
Then paste this parameter block. Do not forget to adapt paths to your configuration
[allusers] comment = All Users path = /home/shares/allusers valid users = @users force group = users create mask = 0660 directory mask = 0771 writable = yes
Update the Samba service configuration
Now that everything is set up, all you have to do is take the new parameters into account. To do this, save the file (CTRL + X then O) and execute the following command
sudo systemctl restart smbd.service
To know the state of the service
pi@orangepiplus2e:~$ sudo systemctl status smbd.service ● smbd.service - LSB: start Samba SMB/CIFS daemon (smbd) Loaded: loaded (/etc/init.d/smbd; bad; vendor preset: enabled) Active: active (running) since mer. 2017-05-10 13:31:45 UTC; 8s ago Docs: man:systemd-sysv-generator(8) Process: 2207 ExecStop=/etc/init.d/smbd stop (code=exited, status=0/SUCCESS) Process: 2215 ExecStart=/etc/init.d/smbd start (code=exited, status=0/SUCCESS) CGroup: /system.slice/smbd.service ├─2226 /usr/sbin/smbd -D ├─2227 /usr/sbin/smbd -D ├─2229 /usr/sbin/smbd -D └─2232 /usr/sbin/smbd -D mai 10 13:31:43 orangepiplus2e systemd[1]: Starting LSB: start Samba SMB/CIFS daemon (smbd)... mai 10 13:31:45 orangepiplus2e smbd[2215]: * Starting SMB/CIFS daemon smbd mai 10 13:31:45 orangepiplus2e smbd[2215]: ...done. mai 10 13:31:45 orangepiplus2e systemd[1]: Started LSB: start Samba SMB/CIFS daemon (smbd). mai 10 13:31:45 orangepiplus2e smbd[2226]: [2017/05/10 13:31:45.401286, 0] ../lib/util/become_daemon.c:124(daemon_ready) mai 10 13:31:45 orangepiplus2e smbd[2226]: STATUS=daemon 'smbd' finished starting up and ready to serve connections
Pour arrêter le service Samba
sudo systemctl stop smbd.service
To restart it (after each modification of the configuration file), execute the command
sudo systemctl restart smbd.service
Access a Raspberry Pi or Orange Pi from macOS
Once Samba has been restarted, open the Finder. On the Finder, the Samba share will be added to a list of shares. This connection method can cause problems. To access the shared folder, it is better to “mount” a network drive. To do this, open the Go menu and choose Connect to Server … (the last option in the menu).
In the address field, type smb://sharename/ . To open the shared folder when opening macOS, click the plus (+) button to add it to the list of preferred servers.
macOS connects to the server. Identify yourself. Check the Keep this password in my keychain box to avoid having to re-enter your password every time you log in.
So, you can now exchange your files very simply with a Raspberry Pi.
Access the shared folder from Windows 10 (or 7, 8, 8.1)
On Windows, it’s a bit the same as on macOS. In the search field (Cortana under Windows 10), locate the Run command.
In the field, type \\name_samba_server and then OK.
Identify and check Remember my credentials.
The folder shared with your Raspberry Pi or Orange Pi opens.
So, you can now upload your files from any other workstation on your local network. The installation and configuration is exactly the same on Raspbian (Raspberry Pi), Armbian (Orange Pi, Cubie Board …) or any PC running Linux. You will be able to access your files both from a Windows PC and MacOS. In this tutorial, we have seen a minimal configuration. Samba is much more powerful. You can manage groups of users, share a printer … To go further, you can read this documentation.
- Install Home Assistant (HASS) on an Orange Pi running under Armbian
- IoT development based on Orange Pi, Arduino (Firmata), Nodejs, Blynk and Johnny-Five
- Blynk + Node.js + Johnny-Five: drive a Pan-Tilt PTZ SG90 kit on Orange Pi with an Arduino / Firmata
- Start programming with Node Js and Johnny-Five: IoT and robotics based on Arduino, Raspberry Pi, Orange Pi
- Orange Pi: test of the OPI.GPIO package for Node-Red (node-red-contrib-opi-gpio)
- Orange Pi (Armbian): replace the GPIO by an Arduino/Firmata, Node-RED and Johnny-Five