🛠 Build an Automated NAS with BPI-CM5

Banana Pi BPI-CM5: Amlogic A311D2 Compute Module with Raspberry Pi CM4 Compatibility · avance · Transformez votre BPI-CM5 en serveur de stockage réseau performant et automatisé grâce à son interface USB 3.0 et son Gigabit Ethernet.

Objectifs

This tutorial aims to configure the Banana Pi BPI-CM5 as a Linux-based NAS (Network Attached Storage) server. We will leverage the speed of the USB 3.0 port to connect an external drive and the Gigabit Ethernet for file sharing. The goal is to automate data backups via a cron script, demonstrating the versatility of the Amlogic A311D2 SoC in a home server context.

Matériel nécessaire

Étapes

  1. System Preparation: Flash a Linux image (e.g., Armbian) onto the SD card. Boot the module and connect the Ethernet cable. An IP address will be assigned automatically via DHCP. Log in via SSH.
  2. Storage Mounting: Plug in the USB drive. Identify it using lsblk. Create a mount point: sudo mkdir /mnt/nas. Mount the drive: sudo mount /dev/sda1 /mnt/nas. To make the mount permanent, add the UUID to /etc/fstab.
  3. Samba Installation: Install the file server: sudo apt update && sudo apt install samba -y. Edit the configuration: sudo nano /etc/samba/smb.conf. Add a [Share] section with path = /mnt/nas, browseable = yes, writable = yes.
  4. User Creation: Create a system user: sudo adduser nasuser. Assign permissions to the folder: sudo chown -R nasuser:nasuser /mnt/nas. Add them to Samba: sudo smbpasswd -a nasuser.
  5. Automation: Create a backup script backup.sh that copies critical data. Make it executable: chmod +x backup.sh. Open the crontab editor: crontab -e. Add a line to run the script every night at 2 AM: 0 2 * * * /home/user/backup.sh.
  6. Service Startup: Restart Samba: sudo systemctl restart smbd. Enable the service on boot: sudo systemctl enable smbd.

Vérification

From another computer, access the BPI-CM5's IP address via the file browser (e.g., smb://<BPI_IP>). You should see the shared folder. Attempt to copy a file there. Check Samba logs (/var/log/samba/) if errors occur. Verify that the backup script runs correctly by checking system logs or creating a log file within the script.

Pour aller plus loin

Explore using the HDMI 2.1 port to display a supervision dashboard (Grafana) directly on a screen. You can also configure a local Web server to serve this data, leveraging the 8-core processor's power to handle network streams and the graphical interface simultaneously.

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials