Turn your Raspberry PI within 15 minutes into a Cloud Network-Attached-Storage/-Server allowing access from remote networks as well as serving any Docker Container.
Inspired by he The MagPi Magazine about creating a NAS with the new Raspberry Pi 4 I added
- cloud-init for automatic provisioning of customized cloud instances,
- rpi-dyndns for dynamic DNS resolution and
- rpi-vpn-server to access the NAS from a remote network and
- based it on HypriotOS for docker host/server functioniality.
If you find this useful, do not forget to star the repository ;-)
- Raspberry PI
- other Hardware
- Dynamic DNS service provider, e.g. from Securepoint
- Before flashing check the user-data.yaml file and
- customise the configuration to your needs manually, eg. change usernames, passwords, packages, network interface, hard disks, etc.
- Than Install HypriotOS a Raspbian based debian derivate, see bootstrapping with cloud-init and download the image from here!
$ curl -LO https://github.com/hypriot/flash/releases/download/2.3.0/flash
$ chmod +x flash
$ ./flash -u user-data.yaml -d /dev/mmcblk0 -f hypriotos-rpi-v1.11.4.img
- Put the SD-Card back into the Raspberry and boot. The NAS will be automatically provisioned and set up - repeatable and reliable :-)
- For configuration of DynDNS and VPN check the repective documentation,
especially
- set the update token for rpi-dyndns,
- import/generate the secrets for rpi-vpn-server, and
- enable port forwarding at your firewall for the UDP ports 500 and 4500.
- Done!
Log into the instance, check the logs at /var/log/cloud-init-output.log
, and run single commands to verify:
$ sudo cloud-init single --name users_groups --frequency always
Edit /boot/user-data
, see the documentation for details. Before reboot, clean up:
$ sudo rm -R /etc/mdadm/mdadm.conf /etc/samba/smb.conf /mnt/raid1/*
$ docker stop ddclient vpnserver && docker rm ddclient vpnserver
$ sudo cloud-init clean --logs --reboot
- reference and load secrets from local environment file
- add uninterruptible power supply, e.g. USB powerbank
- add script to act on "power loss" to shutdown server properly
The MIT License (MIT), see LICENSE file.