🛠 NAS léger : disque USB et partage Samba

Raspberry Pi 3 Model B+ (2018) — Board Sheet · avance · Schéma : IMG-model-3b-plus-avance-3-model3bp-nas-leger-samba.svg — Carte reliée par un hub USB à un disque dur externe alimenté, partages réseau Samba vers les postes du foyer

Objectives

Turn the board into a small home file server: mount an ext4-formatted USB drive, export it via SMB/CIFS using Samba with an authenticated account, and set realistic expectations — the 4 USB ports and Gigabit Ethernet share the same USB 2.0 bus, which caps real transfer speeds at around 300 Mb/s at best over wired connections, and less in practice once the drive is connected.

Hardware

Full code

# 1. Formater (ATTENTION : efface tout) et monter le disque
sudo apt install -y samba
sudo mkfs.ext4 -L nas /dev/sda1        # verifier : lsblk, sudo blkid
sudo mkdir -p /mnt/nas
UUID=$(sudo blkid -s UUID -o value /dev/sda1)
echo "UUID=$UUID /mnt/nas ext4 defaults,noatime 0 2" | sudo tee -a /etc/fstab
sudo mount -a && df -h /mnt/nas

# 2. Export Samba authentifie
sudo mkdir -p /mnt/nas/partage
sudo smbpasswd -a monuser
sudo tee -a /etc/samba/smb.conf >/dev/null <<'EOF'
[partage]
   path = /mnt/nas/partage
   valid users = monuser
   writeable = yes
   create mask = 0664
   directory mask = 0775
EOF
sudo systemctl enable --now smbd

# 3. Test de debit (attendu : bien sous les 300 Mb/s theoriques du bus)
#    cote client : smbclient //IP-CARTE/partage -U monuser

Expected verification

df -h /mnt/nas shows the drive mounted and it survives a reboot (fstab by UUID). From a machine on the network, smb://BOARD-IP/share opens with the created account, with read/write access. testparm -s reports no configuration errors. iperf3 over wired connection approaches 300 Mb/s when the drive is idle; disk-to-network transfers are significantly slower — this is normal (shared USB 2.0 bus).

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials