🛠 Serveur web léger et partage de fichiers (NAS) sur bus USB partagé
Objectives
Leverage the B+ as a discreet server: a static or lightweight web application with lighttpd, and file sharing via Samba, keeping in mind the architectural constraint of the Model B+ — Ethernet and USB ports are connected to the same LAN9514 chip behind a single 480 Mbit/s USB 2.0 bus. It is the web server that frees up the bus for the disk, not the other way around.
Hardware
- Raspberry Pi Model B+ (512 MB RAM) running 32-bit legacy Raspberry Pi OS
- Class 10 microSD card for the system; preferably a powered USB drive or key
- Ethernet cable, open SSH session (network tutorial)
Full code
# Serveur web ultra-léger (pensé pour 512 Mo de RAM)
sudo apt install -y lighttpd
echo "<h1>Model B+ en ligne</h1>" | sudo tee /var/www/html/index.html
sudo systemctl enable --now lighttpd
# Partage d'un disque USB en Samba
sudo apt install -y samba
printf '[donnees]\n path = /mnt/usb\n browseable = yes\n writable = yes\n' | sudo tee -a /etc/samba/smb.conf
sudo mkdir -p /mnt/usb && sudo mount /dev/sda1 /mnt/usb
sudo smbpasswd -a pi && sudo systemctl restart smbd
# Mesurer la réalité du bus partagé (depuis un autre poste)
iperf3 -c 192.168.1.42 # plafond pratique ~10-15 Mo/s
lsusb -t # le LAN9514 porte Ethernet + tous les ports USB
Expected verification
From a browser on the local network, http://192.168.1.42 displays the page; the share \\192.168.1.42\donnees mounts from a PC. iperf3 confirms the realistic ceiling of 10-15 MB/s: it is the bus, not the network. lsusb -t shows the LAN9514 hub above the single USB controller.
Common errors
- Expecting "gigabit" speeds: Ethernet is 10/100 and is anyway throttled by the USB 2.0 bus shared with the disk — transferring and serving simultaneously splits the bandwidth.
- Installing full Apache + PHP: 512 MB of RAM, part of which is taken by the GPU; lighttpd or nginx fit in a few tens of MB.
- Unpowered USB drive: the B+ does not provide enough current on its ports, causing the drive to disconnect and corrupt writes.
- Exposing Samba to the Internet: the legacy image is no longer patched; NAS = local network only, or SSH tunnel.
- Logs and databases on the microSD card: wear kills the cards; put intensive writes on the USB drive.
Other tutorials for this board
- Allumer une LED depuis la GPIO 17 avec libgpiod
- Lire un bouton et afficher les appuis dans la console
- Premier script Python : faire clignoter la LED
- Variation d'intensité d'une LED avec le PWM matériel (GPIO18)
- Interroger un capteur I2C (BME280) sur le bus du 40 broches
- Mettre le B+ en réseau par Ethernet et piloter en SSH
Code examples for this board
led_blink.pyPythonbutton_led.pyPythonservo_sweep.pyPythondht_temp.pyPythonoled_i2c.pyPythonmcp3008_read.pyPython