A Debian-first guide to building a secure and practical network-attached storage (NAS). This guide focuses on real-world usability, proper permissions, and safe defaults.
A NAS (Network Attached Storage) is a centralized storage system that allows multiple devices to access the same files over a network.
In this guide, you will build a NAS using Debian and Samba so it works across:
• Windows
• Linux
• macOS
• Central storage for all devices
• Backup location
• Integrates with your personal cloud
• Full control over your data
In a real NAS setup, your storage directory should be on a separate drive.
Why: This protects your data if the OS drive fails and allows easier expansion later.
sudo apt update
sudo apt full-upgrade -y
What this does:
Updates package lists and installs upgrades.
Why this matters:
Prevents building on outdated software.
sudo apt install -y samba
What this does:
Installs the Samba file-sharing service.
Why this matters:
Samba allows file sharing across different operating systems.
sudo mkdir -p /srv/nas
What this does:
Creates the main shared storage directory.
Why this matters:
Keeps storage separate from system files.
What to expect:
No output means success.
sudo adduser nasuser
What this does:
Creates a system user for NAS access.
Why this matters:
Avoids using shared or anonymous accounts.
sudo chown -R nasuser:nasuser /srv/nas
sudo chmod 750 /srv/nas
What this does:
Assigns ownership and restricts access.
Why this matters:
Prevents unauthorized access.
sudo smbpasswd -a nasuser
What this does:
Adds the user to Samba authentication.
Why this matters:
Samba uses its own password system.
sudo nano /etc/samba/smb.conf
Add:
[NAS]
path = /srv/nas
browseable = yes
read only = no
guest ok = no
valid users = nasuser
What this does:
Creates a secure shared folder.
interfaces = 127.0.0.1 192.168.1.0/24
bind interfaces only = yes
Why this matters:
Limits access to your local network.
sudo systemctl restart smbd
sudo systemctl enable smbd
sudo ufw allow samba
sudo systemctl status smbd
From another device:
\\SERVER-IP\NAS
• Do not expose Samba to the internet
• Use authenticated users only
• Keep system updated
• Restrict access to local network
• Create file
• Delete file
• Reboot system
• Confirm access still works
• Add RAID
• Add backups
• Connect to Nextcloud
• Add remote access