systems:media_server:setup_smb_samba_shares
Table of Contents
Systems - Media Server - Setup SMB (Samba) Shares
To share directories and files between this Linux server and other devices.
Install Samba
sudo apt install samba
Configure the Samba Share
Edit the Samba configuration file, /etc/samba/smb.conf, and add the following section at the end of the file to define the media share:
- /etc/samba/smb.conf
[Media] comment = Contents are read/write by all. path = /mnt/media browseable = yes read only = no guest ok = yes force user = root force group = root force directory mode = 0777 force create mode = 0777
NOTE: The config is:
- [Media] - This is the name of the share.
- When accessing Samba from a client device, this will appear as the share name in the network.
- path = /mnt/media - This specifies the directory on the server that will be shared.
- In this example, the directory /mnt/media is being shared.
- browseable = yes - Setting this to yes allows the share to be visible when browsing the network.
- If set to no, users would need to know the share name to access it manually.
- read only = no - This allows users to write (add, modify, or delete) files in the share.
- If set to yes, the share would be read-only, preventing users from making changes.
- guest ok = yes - Allow guest users to access the share.
- force user = root - Allows all file operations to be performed as the root user, regardless of the username used to connect.
- force group = root - Force group ownership of the share.
- force directory mode = 0777 - Force all created directories to have read, write and execute permissions set for everyone.
- force create mode = 0777 - Force all newly created files to have read, write and execute permissions set for everyone.
Test the Samba Configuration
testparm
Create a Samba User
Add the user on the server user as a Samba user:
sudo smbpasswd -a peter
NOTE: Follow the prompts to create a password for the Samba user.
Samba does not use the system account password, which is why it needs its own password.
- -a - This flag adds the existing linux user to the Samba user database.
- This command searches for the username in the Unix user database and adds it to the Samba user database.
- If not found, then the “smbpasswd” command will create as well as add the user to the Samba group.
Restart Samba Service
Restart the Samba service to apply the changes:
sudo systemctl restart smbd
NOTE: Remember to update any firewall rules to allow Samba traffic
Check the status of the service to confirm that Samba is working fine
sudo systemctl status smbd
systems/media_server/setup_smb_samba_shares.txt · Last modified: 2025/07/12 12:46 by peter