How Samba and Nextcloud work together
Step 1: Install Samba
Step 2: Create a Samba password
Step 3: Configure Samba shares
Step 4: Set permissions
Step 5: Restart Samba
Step 6: Open firewall ports
Step 7: Connect from Mac
Auto-mount on Mac startup
Step 8: Connect from Windows
Map as a network drive (auto-mount):
Step 9: Sync Samba files with Nextcloud
Make it automatic
Step 10: Bulk transfer — the fastest way to load your server
Troubleshooting
What you should have now
What's next In Part 2, we set up Nextcloud with Docker — your own Google Drive with phone auto-backup and desktop sync. That handles cloud-style access perfectly. But sometimes you just want to drag files into a folder. No browser, no app, no sync client — just open Finder on your Mac (or File Explorer on Windows), and there's your server, looking like any other drive. That's what Samba does. It turns your home server into a NAS (Network Attached Storage) that any device on your network can access natively. What you'll have after this guide: This is important to understand before we start. Both Nextcloud and Samba will point to the same storage directory (/srv/nas). This means: They're two doors into the same room. Nextcloud gives you the cloud experience (browser, apps, sharing links). Samba gives you the local network experience (Finder, drag-and-drop, raw speed). 💡 When you add files via Samba, Nextcloud won't detect them automatically. You'll need to run a quick scan command. I'll cover this at the end. SSH into your server and install Samba: Verify it's installed: You should see something like Version 4.x.x. Samba is now installed but not configured yet. Samba uses its own password system, separate from your Linux login. Create a Samba password for your user: Replace your-username with your actual Linux username. It'll ask you to set a password — this is what you'll enter when connecting from your Mac or PC. It can be different from your Linux password. Open the Samba config file: Scroll to the bottom and add your shared folders: Let me explain the key settings: Save and exit (Ctrl+X, then Y, then Enter). Make sure the storage directory has the right ownership: This ensures both Nextcloud (running as www-data) and Samba can read and write to the same files without permission conflicts. The enable command ensures Samba starts automatically after reboots. You should see active (running) in green. If you're running UFW (which you should be — we'll set it up properly in Part 5), allow Samba traffic: These are the standard ports Samba uses for NetBIOS and file sharing. Your server's folders now appear in the Finder sidebar under "Locations." You can drag files in, open them directly, and treat it exactly like a USB drive — except it's over your network. So you don't have to reconnect every time: Your server now shows up as Drive Z: in File Explorer, permanently. When you add files through Samba (drag-and-drop from Mac/PC), Nextcloud doesn't know about them yet. You need to tell Nextcloud to scan for new files: This scans the entire storage directory and adds any new files to Nextcloud's index. Takes a few seconds for small changes, longer for thousands of files. If you're regularly adding files via Samba, set up a cron job to scan every 15 minutes: Now Nextcloud automatically picks up any files you add through Samba within 15 minutes. If you have hundreds of gigabytes of photos and videos to move onto your server, Samba is by far the fastest method. Here's the recommended approach: This is much faster than uploading through Nextcloud's web interface, which has overhead from HTTP and PHP processing. 💡 Transferring a large collection? Use an Ethernet cable for the transfer if possible — you'll see 2-3x faster speeds compared to WiFi. A Cat 6 Ethernet cable costs practically nothing and makes a big difference for bulk transfers. Can't see the server in Finder/File Explorer? "Permission denied" when writing files? Files added via Samba not showing in Nextcloud? Connection drops after Mac sleep? Slow transfer speeds? After following this guide: ✅ Samba installed and configured with NAS, Photos, and Videos shares
✅ Mac or Windows PC sees your server as a network drive✅ Drag-and-drop file transfer at full network speed✅ Auto-mount on startup so the drive is always there✅ Nextcloud synced with Samba via manual scan or cron job✅ A complete NAS setup using hardware you already own Between Nextcloud (Part 2) and Samba (this guide), you now have two ways to access your files: Use both. They complement each other perfectly. Right now, everything works on your home network. But what about when you're not home? 🌐 Part 4: Access your server from anywhere — Set up Tailscale for private encrypted access, get an Oracle Free VPS, configure frp tunneling to bypass CGNAT, set up Nginx and SSL, and point your custom domain to your home server. After Part 4, you'll access your NAS from anywhere in the world. 🔒 Part 5: Security hardening + lessons learned — UFW firewall, Fail2Ban, SSH hardening, monitoring, and everything I wish I'd known before starting. All config files from this series are available in the companion GitHub repo:
👉 github.com/sasrath/homecloud Hit Follow if you don't want to miss Part 4 — that's the one where everything comes together. Drop a comment if you hit any issues with the Samba setup. Your server is now a NAS. Next up: accessing it from anywhere in the world. 🌐 Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse
$ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install samba -y
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install samba -y
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install samba -y
smbd --version
smbd --version
smbd --version
-weight: 600;">sudo smbpasswd -a your-username
-weight: 600;">sudo smbpasswd -a your-username
-weight: 600;">sudo smbpasswd -a your-username
-weight: 600;">sudo nano /etc/samba/smb.conf
-weight: 600;">sudo nano /etc/samba/smb.conf
-weight: 600;">sudo nano /etc/samba/smb.conf
[NAS] path = /srv/nas browseable = yes read only = no valid users = your-username create mask = 0644 directory mask = 0755 force user = www-data force group = www-data [Photos] path = /srv/nas/photos browseable = yes read only = no valid users = your-username create mask = 0644 directory mask = 0755 force user = www-data force group = www-data [Videos] path = /srv/nas/videos browseable = yes read only = no valid users = your-username create mask = 0644 directory mask = 0755 force user = www-data force group = www-data
[NAS] path = /srv/nas browseable = yes read only = no valid users = your-username create mask = 0644 directory mask = 0755 force user = www-data force group = www-data [Photos] path = /srv/nas/photos browseable = yes read only = no valid users = your-username create mask = 0644 directory mask = 0755 force user = www-data force group = www-data [Videos] path = /srv/nas/videos browseable = yes read only = no valid users = your-username create mask = 0644 directory mask = 0755 force user = www-data force group = www-data
[NAS] path = /srv/nas browseable = yes read only = no valid users = your-username create mask = 0644 directory mask = 0755 force user = www-data force group = www-data [Photos] path = /srv/nas/photos browseable = yes read only = no valid users = your-username create mask = 0644 directory mask = 0755 force user = www-data force group = www-data [Videos] path = /srv/nas/videos browseable = yes read only = no valid users = your-username create mask = 0644 directory mask = 0755 force user = www-data force group = www-data
-weight: 600;">sudo chown -R www-data:www-data /srv/nas
-weight: 600;">sudo chmod -R 775 /srv/nas
-weight: 600;">sudo chown -R www-data:www-data /srv/nas
-weight: 600;">sudo chmod -R 775 /srv/nas
-weight: 600;">sudo chown -R www-data:www-data /srv/nas
-weight: 600;">sudo chmod -R 775 /srv/nas
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart smbd
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable smbd
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart smbd
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable smbd
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart smbd
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable smbd
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status smbd
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status smbd
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status smbd
-weight: 600;">sudo ufw allow 137/udp
-weight: 600;">sudo ufw allow 138/udp
-weight: 600;">sudo ufw allow 139/tcp
-weight: 600;">sudo ufw allow 445/tcp
-weight: 600;">sudo ufw allow 137/udp
-weight: 600;">sudo ufw allow 138/udp
-weight: 600;">sudo ufw allow 139/tcp
-weight: 600;">sudo ufw allow 445/tcp
-weight: 600;">sudo ufw allow 137/udp
-weight: 600;">sudo ufw allow 138/udp
-weight: 600;">sudo ufw allow 139/tcp
-weight: 600;">sudo ufw allow 445/tcp
-weight: 500;">docker exec -u www-data nextcloud php occ files:scan --all
-weight: 500;">docker exec -u www-data nextcloud php occ files:scan --all
-weight: 500;">docker exec -u www-data nextcloud php occ files:scan --all
*/15 * * * * -weight: 500;">docker exec -u www-data nextcloud php occ files:scan --all > /dev/null 2>&1
*/15 * * * * -weight: 500;">docker exec -u www-data nextcloud php occ files:scan --all > /dev/null 2>&1
*/15 * * * * -weight: 500;">docker exec -u www-data nextcloud php occ files:scan --all > /dev/null 2>&1
-weight: 500;">docker exec -u www-data nextcloud php occ files:scan --all
-weight: 500;">docker exec -u www-data nextcloud php occ files:scan --all
-weight: 500;">docker exec -u www-data nextcloud php occ files:scan --all - Your server's folders visible in Mac Finder / Windows File Explorer
- Drag-and-drop file transfer at full network speed
- Auto-mount on startup so the drive is always there
- Nextcloud and Samba sharing the same storage — files added via either method are visible in both
- Remote NAS access via Tailscale (set up in Part 4) - Upload a photo via Nextcloud's web interface → it appears in Samba immediately
- Drop a video into the Samba share from your Mac → Nextcloud can see it after a quick scan - path — the directory to share
- browseable = yes — makes it visible when browsing the network
- read only = no — allows writing (uploading files)
- valid users — only this user can access the share
- force user / force group = www-data — this is critical. Nextcloud runs as www-data, so any file created via Samba must also be owned by www-data. Without this, Nextcloud can't read files you add through Samba. - Open Finder
- Press Cmd+K (or click Go → Connect to Server)
- Type: smb://192.168.1.100 (replace with your server's IP)
- Click Connect
- Select Registered User
- Enter your username and the Samba password you created in Step 2
- Select which shares to mount: NAS, Photos, Videos - Connect to the NAS using the steps above
- Go to System Settings → General → Login Items
- Click + under "Open at Login"
- Navigate to Network → your server IP → select the NAS folder
- The drive now mounts automatically every time your Mac starts - Open File Explorer
- Click the address bar at the top
- Type: \\192.168.1.100 (backslashes, not forward slashes)
- Press Enter
- Enter your username and Samba password
- Check "Remember my credentials" if you want auto-login
- Your shares appear as network folders - Right-click on the share folder
- Click Map network drive
- Choose a drive letter (e.g., Z:)
- Check Reconnect at sign-in
- Click Finish - Connect via Samba from your Mac or PC (Steps 7 or 8)
- Drag and drop your files into the appropriate folders (photos → Photos, videos → Videos)
- Wait for transfer to complete — local network transfers are fast, typically 50-100 MB/s over WiFi, faster over Ethernet
- Run the Nextcloud scan once the transfer is done: - Make sure you're on the same WiFi network as the server
- Try connecting directly via IP: smb://192.168.1.100 (Mac) or \\192.168.1.100 (Windows)
- Check Samba is running: -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status smbd - Check ownership: ls -la /srv/nas/ — files should be owned by www-data
- Fix permissions: -weight: 600;">sudo chown -R www-data:www-data /srv/nas
- Make sure your smb.conf has force user = www-data - Run the scan: -weight: 500;">docker exec -u www-data nextcloud php occ files:scan --all
- Or wait for the cron job if you set one up - This is normal. The Mac disconnects SMB shares when it sleeps. It should auto-reconnect when it wakes up if you set up auto-mount (Step 7). If not, just press Cmd+K and reconnect. - Switch to a wired connection. WiFi has overhead and interference. An Ethernet connection will give you significantly faster and more reliable transfers.