With Samba, a Raspberry Pi becomes a small file server: a folder or USB drive you see from Windows and macOS like any network drive. This guide explains how to install it, mount the drive reliably and connect from both systems.
In short
- Samba implements SMB, the file sharing protocol Windows and macOS understand without installing anything.
- It is configured in
/etc/samba/smb.confand each user needs a separate Samba password (smbpasswd -a).- For a USB drive, mount it by UUID in
/etc/fstabwith thenofailoption so the Pi boots even if it is missing.
You need an updated Raspberry Pi OS, SSH access and ideally a static IP.
What you will build

| Item | Example in this guide |
|---|---|
| Raspberry Pi IP | 192.168.1.10 |
| Pi user | pi |
| Shared folder | /srv/compartido or the drive at /mnt/disco |
| Network share name | compartido and disco |
Change these values to yours.
Step 1: install Samba
sudo apt update
sudo apt install samba samba-common-bin
If it asks about WINS/DHCP configuration during install, answer No.
Step 2: create the shared folder
sudo mkdir -p /srv/compartido
sudo chown pi:pi /srv/compartido
The owner matters: Samba accesses files with the permissions of the Linux user you connect with. If the folder belongs to root, you will see it but not write.
Step 3: prepare a USB drive (optional)
If you want to share an external drive, connect it and find it:
lsblk -f
You will see something like:
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
└─sda1 ext4 datos 3f2a1c9e-7b4d-4e0a-9c1f-1a2b3c4d5e6f
Which file system to use
| Format | Recommendation |
|---|---|
| ext4 | Best if the drive stays on the Pi: Linux permissions, robust and fast |
| exFAT | Useful if you sometimes plug it straight into Windows or Mac |
| NTFS | Works, but with more permission limitations |
To choose in more detail, see file systems explained.
Mount it permanently
Create the mount point and edit /etc/fstab:
sudo mkdir -p /mnt/disco
sudo nano /etc/fstab

Add a line with your drive’s UUID:
UUID=3f2a1c9e-7b4d-4e0a-9c1f-1a2b3c4d5e6f /mnt/disco ext4 defaults,nofail 0 2
- UUID instead of
/dev/sda1: thesdaname can change if you connect another drive. - nofail: if the drive is absent, the Pi boots anyway instead of stalling.
Test the line without rebooting and set permissions:
sudo systemctl daemon-reload
sudo mount -a
sudo chown pi:pi /mnt/disco
If mount -a gives no errors, you are good.
Step 4: configure the shares
Back up the original file and edit it:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.orig
sudo nano /etc/samba/smb.conf
At the end of the file, add:
[compartido]
path = /srv/compartido
browseable = yes
read only = no
valid users = pi
create mask = 0664
directory mask = 0775
[disco]
path = /mnt/disco
browseable = yes
read only = no
valid users = pi
| Option | What it does |
|---|---|
path | Actual folder shared |
browseable | Appears when browsing the server |
read only = no | Allows writing |
valid users | Only those users can enter |
create mask / directory mask | Permissions of new files and folders |
Check the syntax:
testparm
Step 5: create the Samba password
Samba does not use the Linux password. Create one for the user:
sudo smbpasswd -a pi
Restart the service:
sudo systemctl restart smbd
Step 6: connect from Windows
- Open File Explorer.
- In the address bar type
\\192.168.1.10\compartidoand press Enter. - Enter user
piand the Samba password.
To keep it as a fixed drive, right-click This PC → Map network drive, pick a letter and paste the same path. From the console:
net use Z: \\192.168.1.10\compartido /user:pi /persistent:yes
Step 7: connect from macOS
- In the Finder, menu Go → Connect to Server (⌘K).
- Type
smb://192.168.1.10/compartidoand click Connect. - Choose Registered User and enter
piand the Samba password.
To mount it at login, add the mounted volume to Login Items under System Settings → General.
Common problems
| Symptom | Cause and fix |
|---|---|
| Access denied when writing | The folder belongs to root. Use chown with your user |
| The password does not work | You missed smbpasswd -a or are using the Linux one. They differ |
| Windows cannot find the server | Use the IP directly instead of the name |
| The drive share looks empty | The drive is not mounted. Check lsblk and mount -a |
| The Pi will not boot after editing fstab | Error in the line and nofail missing. Fix /etc/fstab from another computer reading the microSD |
| Slow transfers | Wi-Fi or USB 2.0 drive. Use cable and a USB 3.0 (blue) port |
If the problem is on the Windows side, see Windows is not sharing folders or printers.
Frequently asked questions
Can I set up guest access without a password?
You can, but current Windows versions block SMB guest access by default for security. Using a user and password avoids problems.
Does it count as a backup?
It is a good backup destination, but a single drive is not a backup: if it fails, you lose everything. Read RAID explained to understand why.



