{"id":13578442,"url":"https://github.com/timoknapp/rpi-nas","last_synced_at":"2025-09-11T16:13:45.606Z","repository":{"id":103300248,"uuid":"231909462","full_name":"timoknapp/rpi-nas","owner":"timoknapp","description":"🌐👨‍💻💻 Setup your own NAS on a Raspberry Pi","archived":false,"fork":false,"pushed_at":"2024-07-16T12:03:56.000Z","size":6663,"stargazers_count":72,"open_issues_count":0,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T00:04:17.438Z","etag":null,"topics":["cloudcmd","docker","docker-compose","hacktoberfest","heimdall","nas","openmediavault","plex","plex-media-server","portainer","pyload","raspberry-pi"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timoknapp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-01-05T11:49:40.000Z","updated_at":"2025-04-04T16:02:50.000Z","dependencies_parsed_at":"2023-09-22T18:26:27.513Z","dependency_job_id":"2607ba13-7d6b-4335-9fcb-d131653cc83d","html_url":"https://github.com/timoknapp/rpi-nas","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/timoknapp/rpi-nas","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoknapp%2Frpi-nas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoknapp%2Frpi-nas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoknapp%2Frpi-nas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoknapp%2Frpi-nas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timoknapp","download_url":"https://codeload.github.com/timoknapp/rpi-nas/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoknapp%2Frpi-nas/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262477037,"owners_count":23317405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudcmd","docker","docker-compose","hacktoberfest","heimdall","nas","openmediavault","plex","plex-media-server","portainer","pyload","raspberry-pi"],"created_at":"2024-08-01T15:01:30.683Z","updated_at":"2025-06-28T18:35:00.995Z","avatar_url":"https://github.com/timoknapp.png","language":null,"funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"# Raspberry PI NAS\n\nSetup your own NAS on a Raspberry Pi.\n\n## Preview\n\n### Dashboard\n\n![dashboard](screenshots/dashboard.jpg)\n\n### Monitoring\n\n![grafana](screenshots/grafana.jpg)\n\n## Table of Contents\n\n- [Hardware](#hardware)\n- [OS](#os)\n  * [SSH](#ssh)\n- [SMB Shares](#smb-shares)\n  * [Format Drives](#format-drives)\n  * [Mount Drives](#mount-drives)\n    + [Prepare Disks](#prepare-disks)\n    + [Mount Disks manually](#mount-disks-manually)\n    + [Mount Disks automatically](#mount-disks-automatically)\n  * [Setup SMB Server](#setup-smb-server)\n  * [Setup TimeMachine Share](#setup-timemachine-share)\n  * [Other useful things](#other-useful-things)\n    + [HD-Idle](#hd-idle)\n    + [Log2Ram](#log2ram)\n    + [Check Disk Utilization](#check-disk-utilization)\n- [Docker Setup](#docker-setup)\n  * [Install Docker](#install-docker)\n  * [Prepare Docker Environment](#prepare-docker-environment)\n    + [1. Clone Repository](#1-clone-repository)\n    + [2. Configure your Setup](#2-configure-your-setup)\n    + [3. Run Compose-Stack](#3-run-compose-stack)\n    + [4. Try it out](#4-try-it-out)\n  * [Components](#components)\n    + [Configure Pi-hole](#configure-pi-hole)\n- [CloudflareD](#cloudflared)\n\n## Hardware\n\n- [Raspberry Pi 4 4GB](https://www.raspberrypi.com/products/raspberry-pi-4-model-b/)\n- [SD Card 32GB (Silicon Power)](https://www.amazon.de/dp/B07RMXNLF4?psc=1\u0026ref=ppx_yo2ov_dt_b_product_details)\n- [QNAP TR-004 RAID Storage (RAID 5)](https://www.qnap.com/en-us/product/tr-004)\n- [SEAGATE IronWolf 4TB (ST4000VN006)](https://www.seagate.com/de/de/products/nas-drives/ironwolf-hard-drive/)\n\nIf you want to use a software based RAID setup instead, you need to format your drives first. You can use the following guides to setup a RAID 5 with Btfs:\n\n- [RAID 5 with Btfs](https://archive.kernel.org/oldwiki/btrfs.wiki.kernel.org/index.php/Using_Btrfs_with_Multiple_Devices.html#)\n- [New documentation](https://btrfs.readthedocs.io/en/latest/mkfs.btrfs.html#multiple-devices)\n\n## OS\n\n- 64 bit Raspbian\n- Vanilla Rasbperry Pi OS Bullseye (e.g. Raspberry Pi OS LITE 64 bit) [Installation guide](https://www.raspberrypi.com/software/)\n\n### SSH\n\nMore documentation to [enable SSH](https://www.raspberrypi.org/documentation/remote-access/ssh/README.md) or [generate Keys](https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md).\n\n```bash\n# Enable SSH\nsudo systemctl enable ssh\nsudo systemctl start ssh\n\n# SSH Keys\nssh-keygen -t rsa -b 4096 -C\n```\n\n## SMB Shares\n\n### Format Drives\n\n```bash\n# List Disks\nsudo fdisk -l\n\n# Open Disk (replace X with the disk letter)\nsudo fdisk /dev/sdX \n\n# Create Partititon\nn\ndefault\ndefault\ndefault\nw\n\n# Check Table\nsudo fdisk -l\n\n# Format the partition (replace X with the disk letter)\nsudo mkfs -t ext4 /dev/sdX1\n```\n\nMore documentation can be found [here](https://phoenixnap.com/kb/linux-create-partition).\n\n### Mount Drives\n\n#### Prepare Disks\n\nIn order to identify the disks with a descriptive name, we need to add a label to the disks. This can be done with the following commands.\n\n```bash\n# List Disks\nsudo fdisk -l\n\n# Goal state\n# /dev/disk/by-label/qnap (8TB)        | LABEL=\"qnap\"\n\n# Add Label to Disks: (replace X with the disk letter)\nsudo e2label /dev/sdX1 qnap\n```\n\n#### Mount Disks manually\n\n```bash\n# Change Owner of /mnt directory (Otherwise SMB Shares cannot be mounted)\nsudo chown root:users /mnt\n\n# Create Mount Points\nsudo mkdir /mnt/qnap\n\n# Check Permissions\nstat /mnt/qnap\n\n# Change Owner (replace $USER with your username)\nsudo chown -R $USER:users /mnt/qnap/*\n\n# Change Permissions\nchmod -R 775 /mnt/qnap/*\n\n# Mount Disks\nmount /dev/disk/by-label/qnap /mnt/qnap/\n\n# (Optional) Mount Disks with User Permissions\nmount -o user=$USER /dev/disk/by-label/qnap /mnt/qnap/\n```\n\nMore documentation can be found [here](https://linuxhint.com/mount_usb_drive_debian/).\n\n#### Mount Disks automatically\n\n```bash\n# Identify UUIDs or Labels of the disks\nsudo blkid\n# Edit /etc/fstab\nsudo nano /etc/fstab\n# Add the following lines to /etc/fstab\n#LABEL=qnap /mnt/qnap ext4 nofail,x-systemd.device-timeout=1ms 0 0\nLABEL=qnap /mnt/qnap ext4 defaults 0 0\n```\n\nMore documentation can be found [here](https://raspberrypi-guide.github.io/filesharing/mounting-external-drive#set-up-automatic-mounting).\n\n### Setup SMB Server\n\n```bash\nsudo apt-get update\nsudo apt-get upgrade\n\n# Install Samba\nsudo apt-get install samba samba-common-bin\n\n# Setup Shares\nsudo nano /etc/samba/smb.conf\n\n# Add Configuration to smb.conf (replace $USER with your username)\nComment out all lines under \"Share Definitions\" and add the following lines:\n\n[nas]\n    path = /mnt/qnap/nas\n    writeable = Yes\n    create mask = 0775\n    directory mask = 0775\n    public = no\n    force user = $USER\n    force group = $USER\n\n[timemachine]\n    path = /mnt/qnap/timemachine\n    writeable = Yes\n    vfs objects = catia fruit streams_xattr\n    fruit:time machine = yes\n    public = no\n\n# Setup SMB User (replace $USER with your username)\nsudo smbpasswd -a $USER\n\n# Restart Samba service\nsudo systemctl restart smbd\n\n# Check SMB Status including Version\nsudo smbstatus\n```\n\nMore documentation can be found [here](https://pimylifeup.com/raspberry-pi-samba/) and [here](https://www.jeffgeerling.com/blog/2021/htgwa-create-samba-smb-share-on-raspberry-pi).\n\n### Setup TimeMachine Share\n\n```bash\n# Check if Avahi service is running\nsudo systemctl status avahi-daemon\n\n# If the `avahi-daemon` is not installed, install it with the following command:\nsudo apt install avahi-daemon\n\nsudo nano /etc/avahi/services/samba.service\n\n# Add Configuration to samba.service\n# You can choose different Icons of your Server based on this file\n# /System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist\n# https://simonwheatley.co.uk/2008/04/avahi-finder-icons/\n\u003c?xml version=\"1.0\" standalone='no'?\u003e\u003c!--*-nxml-*--\u003e\n\u003c!DOCTYPE service-group SYSTEM \"avahi-service.dtd\"\u003e\n\u003cservice-group\u003e\n  \u003cname replace-wildcards=\"yes\"\u003e%h\u003c/name\u003e\n  \u003cservice\u003e\n    \u003ctype\u003e_smb._tcp\u003c/type\u003e\n    \u003cport\u003e445\u003c/port\u003e\n  \u003c/service\u003e\n  \u003cservice\u003e\n    \u003ctype\u003e_device-info._tcp\u003c/type\u003e\n    \u003cport\u003e9\u003c/port\u003e\n    \u003ctxt-record\u003emodel=RackMac3,1\u003c/txt-record\u003e\n    \u003ctxt-record\u003emodel=MacPro7,1@ECOLOR=226,226,224\u003c/txt-record\u003e\n  \u003c/service\u003e\n  \u003cservice\u003e\n    \u003ctype\u003e_adisk._tcp\u003c/type\u003e\n    \u003cport\u003e9\u003c/port\u003e\n    \u003ctxt-record\u003edk0=adVN=timemachine,adVF=0x82\u003c/txt-record\u003e\n    \u003ctxt-record\u003esys=adVF=0x100\u003c/txt-record\u003e\n  \u003c/service\u003e\n\u003c/service-group\u003e\n\n# Restart Avahi service\nsudo systemctl restart avahi-daemon\n```\n\nMore documentation can be found [here](https://ovechkin.xyz/blog/2021-12-13-using-raspberry-pi-for-time-machine). After modifying the samba.service file, the TimeMachine share should be visible in the Finder.\n\n### Other useful things\n\n#### HD-Idle\n\nSetup HDD spin down times to save energy and increase lifetime of the disks.\n\n```bash\n# Install hd-idle\nsudo apt install hd-idle\n# Configure hd-idle\nsudo nano /etc/default/hd-idle\n\n# Change line according to your available disks. Replace X with the disk letter.\n# The following line will set the default to 0 and the custom idle time for disk sdX to 8 minutes. Save File afterwards.\nHD_IDLE_OPTS=\"-i 0 -a sdX -i 480 -l /var/log/hd-idle.log\"\n\n# Configure hd-idle service\nsudo nano /lib/systemd/system/hd-idle.service\n\n# Add the following lines in the \"[Service]\" section\n# This will make sure that the service will be restarted in case of errors.\n[Service]\n...\nRestart=always\nRestartSec=3\n\n# Restart Systemd Deamon\nsudo systemctl daemon-reload\n\n# Restart hd-idle\nsudo systemctl restart hd-idle\n\n# Check if hd-idle is running\nsystemctl status hd-idle\n\n# Check if disks are spinning down\ncat /var/log/hd-idle.log\n```\n\nMore documentation can be found [here](https://www.htpcguides.com/spin-down-and-manage-hard-drive-power-on-raspberry-pi/)\n\n#### Log2Ram\n\n```bash\nsudo apt update\nsudo apt install log2ram\n\n# Check if log2ram is running (after reboot!)\nsystemctl status log2ram\n```\n\nMore documentation can be found [here](https://github.com/azlux/log2ram).\n\n#### Check Disk Utilization\n\n```bash\ndf -h\n```\n\n## Docker Setup\n\n### Install Docker\n\nI recommend to install it yourself following a simple [guide](https://dev.to/rohansawant/installing-docker-and-docker-compose-on-the-raspberry-pi-in-5-simple-steps-3mgl).\n\n### Prepare Docker Environment\n\nAll following commands need to be run from your Raspberry PI. Either connect via `SSH` or direct access.\n\n#### 1. Clone Repository\n\n```bash\ngit clone https://github.com/timoknapp/rpi-nas.git\ncd rpi-nas\n```\n\n#### 2. Configure your Setup\n\nReplace Placeholders in `docker-compose.yml` file:\n\n- ${PATH_TO_DISK} with related Path on your PI\n- Execute the following command on your PI:  ``id `whoami` ``\n  - Replace ${USER_ID} with the integer value of `uid`.\n  - Replace ${GROUP_ID} with the integer value of `gid`.\n\n- Set password `postgres` user\n\n#### 3. Run Compose-Stack\n\n```bash\ndocker-compose up\n```\n\n#### 4. Try it out\n\nOpening a browser with the IP of your PI should show now the Heimdall dashboard. A configured dashboard would like like one on top. (e.g. `http://IP-OF-YOUR-PI`)\n\n### Components\n\nFollowing show all the applications of the `docker-compose.yml` related to their exposed ports on the host.\n\n| Application | Port | URL | Optional |\n| ------------| ---- | --- | -------- |\n| [Portainer](https://github.com/portainer/portainer) | 9000 | http://localhost:9000 | |\n| [Heimdall Dashboard](https://github.com/linuxserver/Heimdall) | 80, 443 | http://localhost, https://localhost | |\n| [Pi-hole](https://github.com/pi-hole/docker-pi-hole) | 53, 8080 | http://localhost:8080 | |\n| [CloudflareD](https://github.com/cloudflare/cloudflared) | - | | |\n| [Homebridge](https://github.com/homebridge/homebridge) | 8581 | http://localhost:8581 | |\n| [Deconz Conbee](https://github.com/deconz-community/deconz-docker) | 8888, 8443 | http://localhost:8888, https://localhost:8443 | |\n| [Plex](https://github.com/linuxserver/docker-plex) | 32400 | http://localhost:32400/web/index.html | yes |\n| [CloudCmd](https://github.com/coderaiser/cloudcmd) | 8008 | http://localhost:8008 | yes |\n| [pyLoad](https://github.com/linuxserver/docker-pyload) | 8088 | http://localhost:8088 | |\n| [Nextcloud](https://github.com/nextcloud/server) | 8081 | http://localhost:8081 | yes |\n| [Home-Assistant](https://github.com/home-assistant/core)(1) | 8123 | http://localhost:8123 | yes |\n| [Grafana](https://github.com/grafana/grafana) | 3000 | http://localhost:3000 | |\n| [InfluxDB](https://github.com/influxdata/influxdb) | - | | |\n| [Telegraf](https://github.com/influxdata/telegraf) | - | | |\n| [Internet Speedtest](https://github.com/kjake/internet-speedtest-docker) | - | | yes |\n\nOptional means that the application is not necessary for the NAS to work properly. It is just a nice to have. If you want to use it, you need to uncomment the related lines in the `docker-compose.yml` file.\n\n(1) In order to expose your external devices using Zigbee/Z-Wave dongles to the Home Assistant container, you can read this [guide](https://www.home-assistant.io/docs/installation/docker/#exposing-devices)\n\n#### Configure Pi-hole\n\n- Open `http://IP-OF-YOUR-PI:8080/admin` and login with the password you set in the `docker-compose.yml` file.\n- Go to `Settings` -\u003e `DNS` -\u003e `Interface settings` and change the setting from `Allow only local requests` to `Permit all origins` -\u003e `Save`. (This could already be set by the environment variable [`DNSMASQ_LISTENING`](https://github.com/pi-hole/docker-pi-hole?tab=readme-ov-file#optional-variables) in the `docker-compose.yml` file)\n  - This will add the following line in `/etc/dnsmasq.d/01-pihole.conf`:\n\n  ```bash\n  except-interface=nonexisting\n  ```\n\n  \u003e Since the Pi-hole is running in a docker container, it is not possible to use the `Allow only local requests` setting as its only considering the local network of the container.\n- Go to `Settings` -\u003e `System` -\u003e `Disable Query Logging`.\n  \u003e Since we want to use the Pi-hole as a DNS server only, we don't need to log any queries. This will reduce the amount of writes to the disk and will allow us to run Pi-hole in anonymous mode.\n- Add the following lines to `/etc/pihole/pihole-FTL.conf`:\n\n  ```bash\n  PRIVACYLEVEL=3 #; 0=show everything, 1=hide domains, 2=hide domains and clients, 3=anonymous mode\n  #; MAXLOGAGE=24.0 #; up to how many hours of logs to show in pihole web interface\n  MAXDBDAYS=7 #; delete entries older than 30 days. Setting this to 0 will disable the database.\n  DBINTERVAL=60.0 #; write to the pihole-FTL.db file every 30 minutes (lets the HDD spin down)\n  #; DBFILE=/etc/pihole/pihole-FTL.db #; path to the database file. Setting this to DBFILE= disables the database altogether\n  ```\n  \n- Restart Pi-hole container!\n\n#### Configure CloudflareD\n\nTdb.\n\n- Add your Cloudflare API Token to the `TUNNEL_TOKEN` variable in the `docker-compose.yml` file.\n\nMore configuration options can be found [here](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/) or [here](https://docs.pi-hole.net/guides/dns/cloudflared/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimoknapp%2Frpi-nas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimoknapp%2Frpi-nas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimoknapp%2Frpi-nas/lists"}