🛠 Build an Automated NAS with BPI-CM5
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
- Banana Pi BPI-CM5 module (installed on a CM4-compatible carrier board)
- Stable USB-C power supply (5V/3A recommended)
- External USB 3.0 hard drive or SSD (formatted as ext4)
- RJ45 Ethernet cable
- SD card for the operating system (Ubuntu or Armbian)
- SSH access to the module
Étapes
- 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.
- 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. - 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 withpath = /mnt/nas,browseable = yes,writable = yes. - 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. - Automation: Create a backup script
backup.shthat 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. - 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.