From 40c0d09945fdf21601b5b62af9d16b0c254a92b6 Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Wed, 4 Jan 2023 15:13:48 -0500 Subject: draft: alpine stuff --- README.md | 111 ++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 64 insertions(+), 47 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 718cbf6..1d7c194 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,14 @@ My requirements are as follows: | | Email | n/a | | :heavy_check_mark: | Syncing/Sharing files, calender, contacts, tasks etc. | [Nextcloud](https://nextcloud.com/) | | :heavy_check_mark: | Hosting misc. static websites | [Nginx](https://www.nginx.com/) | -| :heavy_check_mark: | Media (pictures, tv, movies) Server | [Jellyfin](https://jellyfin.org/) | +| :heavy_check_mark: | Media (pictures, tv, movies) Server | [Plex](https://plex.tv) or [Jellyfin](https://jellyfin.org/) | | :heavy_check_mark: | Meta Search Engine | [Searxng](https://docs.searxng.org/) | | :heavy_check_mark: | Music Server | [Navidrome](https://www.navidrome.org/) | | :heavy_check_mark: | Network accessible storage for media | [Samba](https://www.samba.org/) | | :heavy_check_mark: | Password Hosting/Share | [Bitwarden](https://bitwarden.com/) | | :heavy_check_mark: | VPN | [Wireguard](https://www.wireguard.com/) | | :heavy_check_mark: | Torrents | [Transmission](https://transmissionbt.com/) | +| :heavy_check_mark: | Photo sharing | [Photoprism](https://photoprism.app) | | :heavy_check_mark: | Media downloader | [Sonarr](https://github.com/Sonarr/Sonarr), [Radarr](https://github.com/Radarr/Radarr), [Prowlarr](https://github.com/Prowlarr/Prowlarr) | > Consider items marked as :heavy_check_mark: above to be implemented in this repo. @@ -32,7 +33,7 @@ I don't want it to have much of an impact on my utility (power) bill, which of c so much heat that it requires advanced cooling. ## Architecture -![Architecture](./architecture.png) +![Architecture](./pix/architecture.png) Notice that this setup requires a very small VPS since we are just running a wireguard client on it. All storage, and compute is being done by the Home Server. This means that my cost went from ~ $13/mo to ~ $1/mo for the VPS service, *while* increasing my SSD storage capacity from 50GB to 2TB (or whatever you have lying around)! And this does not incude the cost savings from self-hosting many of these services in the first place. @@ -46,71 +47,87 @@ There are many cheap VPS providers out there. I use Racknerd now. I have used Vu ## Pre-requisites ### Equipment -1. Raspberry Pi 4B (4GB). -2. USB Hub with **with its own power source**. -3. 2 X TiB external usb SSDs or HDDs for our network-attached-storage (NAS). -4. (optional, but recommended) 1 external usb SSD or HDD as a backup drive. -5. A very cheap VPS - I use Racknerd. +> The equipment I use reflect my current priorities and have changed since this project started and will +continue to change in the future. + +A [ROCKPro64](https://wiki.pine64.org/wiki/ROCKPro64) 4G model. +Alternatively, an RPi4 or similar would also work if you can get your hands on it. +![ROCKPro64](./pix/board.png) + +There are many reasons why this board is awesome: +1. In Stock. +2. Similar price/performance/energy usage as the RPi4. +3. PCIe slot!! + +My main reason for switching to this board is the final point above :) + +Speaking of the PCIe slot, we can get a PCIe SATA adapter to connect to two SATA drives. +![Dual SATA Adapter](./pix/pcie_sata.png) + +To power the drives, Pine64 all sells power cables: +![SATA power cables](./pix/sata_power.png) + +The drives themselves are 4 TiB 3.5in 5400 RPM CMR such as: +![Drive 1](./pix/wd.png) + +> 7200 RPM drives are more expensive and I won't be pushing this hard enough to notice the benefits. +> Note there will be cheaper drives using SMR, but I'd recommend CMR is worth the extra cost. + +Remember to buy drives that are not made as part of the same batch, so that the probabity of them +dying together is the lowest. You can also do this by buying different brands. + +Also remember to buy an extra set so that you save yourself some panic during recovery. + +When using the dual SATA adapter, Pine64 recommends a beefier 12V, 3A power-supply: +![PSU](./pix/psu.png) + +Since this is basically a NAS build, I opted to house all of this in: +![NAS Case](./pix/case.png) +Which comes included with a fan, and the SATA power-cables. + +Optional, but recommended: an external usb SSD or HDD as a backup drive. + +An finally, a very cheap VPS (Virtual Private Server) - I use Racknerd. +This will give you access to a reliable static IP. ### Base Image setup -For numerous reasons, I have switched to using Alpine Linux `aarch64` as the base OS image. -Going forward this repo will primarily be geared towards it. -That being said, all existing roles will continue to work on Raspi OS (debian) based images as well. - -1. Follow instructions from [Alpine wiki](https://wiki.alpinelinux.org/wiki/Raspberry_Pi) to create a bootable SD card. -2. During the `setup-alpine` process, select the **sys** mode for a persistent install. -3. Reboot -4. -```bash -# TODO: Make these tasks part of an Ansible role. -echo "dtoverlay=gpio-fan,gpiopin=14,temp=70000" > /boot/usercfg.txt - -# enable community packages in /etc/apk/repositories -# enable http://dl-cdn.alpinelinux.org/alpine/edge/testing -apk update -apk upgrade -apk add vim nnn htop bmon rsync py3-pip -apk add wireguard-tools docker docker-compose certbot -modprobe wireguard -# add wireguard to /etc/modules # - -# docker stuff -addgroup username docker -rc-update add docker boot -service docker start -``` -5. Continue to the NAS Setup section. +I have switched to using DietPi images (from Alpine) as they support my hardware, as well as RPis. + +1. Follow instructions from [DietPi wiki](https://dietpi.com/docs/install/) to create a bootable SD card and boot up. +2. On first boot, I recommend you change your `root` password, and change the SSH server to use OpenSSH (from Dropbear). +This makes running automation against it easier. +3. Then you can run our playbook with the `base` tag to install all pre-requisite software. +4. You should then setup your drives according to your needs. If you are doing ZFS, the section below might be useful. ### NAS Setup -As a minimum, I recommend setting up two of the external usb drives as a ZFS mirrored pool. +I recommend setting up the two drives as a ZFS mirrored pool. This will allow you to lose up to one drive at a time, and still operate in a degraded state while you replace it. ```bash -# install zfs -apk add udev zfs -modprobe zfs -# add zfs to /etc/modules # +# Install zfs (the base role will do this for you if using a rockpro64) +# Otherwise there are usually two steps: +# 1. Install the kernel headers for your kernel. +# 2. Install the zfs-dkms, and zfsutils-linux packages. + # verify install zfs --version -rc-update add udev sysinit -rc-update add udev-trigger sysinit # assuming your first drive is /dev/sda -zpool create yourpool /dev/sda -zpool export yourpool -zpool import -d /dev/disk/by-id/usb-Samsung_PSSD_T7_Shield_S6SMNS0T701007V-0:0-part1 yourpool -N +# get the ids -> /dev/sdX mapping of your disks by +ls -al /dev/disk/by-id/ +# using ids is recommened because then zpool status will instantly tell you +# which disk in reality is problematic, rather than sda,sdb etc. +zpool create yourpool mirror /dev/disk/by-id/yourdisk1 /dev/disk/by-id/yourdisk2 zfs set mountpoint=/mnt/yourpool yourpool # create datasets zfs create yourpool/media zfs create yourpool/data # for encrypted datasets zfs create -o encryption=on -o keylocation=prompt -o keyformat=passphrase yourpool/priv -# add the second drive to the pool -zpool attach yourpool usb-Samsung_PSSD_T7_Shield_S6SMNS0T701007V-0:0 usb-Samsung_PSSD_T7_S5T3NJ0N907662T-0:0 # zfs useful cmds -zpool scrub yourpool zpool status -v yourpool +zpool scrub yourpool zfs get mountpoint zfs mount -l yourpool/data zfs mount -l yourpool/media -- cgit v1.2.3 From 54087a98772dfc6f0af2a3f6725cc943a75747e4 Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Wed, 4 Jan 2023 15:16:51 -0500 Subject: more up --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index 1d7c194..b62b369 100644 --- a/README.md +++ b/README.md @@ -60,17 +60,20 @@ There are many reasons why this board is awesome: 3. PCIe slot!! My main reason for switching to this board is the final point above :) - Speaking of the PCIe slot, we can get a PCIe SATA adapter to connect to two SATA drives. + ![Dual SATA Adapter](./pix/pcie_sata.png) To power the drives, Pine64 all sells power cables: + ![SATA power cables](./pix/sata_power.png) The drives themselves are 4 TiB 3.5in 5400 RPM CMR such as: + ![Drive 1](./pix/wd.png) > 7200 RPM drives are more expensive and I won't be pushing this hard enough to notice the benefits. + > Note there will be cheaper drives using SMR, but I'd recommend CMR is worth the extra cost. Remember to buy drives that are not made as part of the same batch, so that the probabity of them @@ -79,10 +82,13 @@ dying together is the lowest. You can also do this by buying different brands. Also remember to buy an extra set so that you save yourself some panic during recovery. When using the dual SATA adapter, Pine64 recommends a beefier 12V, 3A power-supply: + ![PSU](./pix/psu.png) Since this is basically a NAS build, I opted to house all of this in: + ![NAS Case](./pix/case.png) + Which comes included with a fan, and the SATA power-cables. Optional, but recommended: an external usb SSD or HDD as a backup drive. -- cgit v1.2.3 From 5081add0ce307a1632246709f7d9b18f8e9173a2 Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Wed, 4 Jan 2023 15:26:05 -0500 Subject: more --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index b62b369..ab1c350 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # My Homelab Setup -**This is still very much un-stable, and very much a work-in-progress.** +**This is project is now somewhat stable but still a work-in-progress.** So I decided to migrate *most* of my remote VPS to a self-hosted private server. There are 3 reasons for this: 1. Cost savings. VPS SSD storage can get quite [expensive](https://racknerd.com/kvm-vps) as your storage demands increase. Meanwhile I have a few SSDs lying my house around not being utilized. @@ -81,13 +81,14 @@ dying together is the lowest. You can also do this by buying different brands. Also remember to buy an extra set so that you save yourself some panic during recovery. -When using the dual SATA adapter, Pine64 recommends a beefier 12V, 3A power-supply: +When using the dual SATA adapter, Pine64 recommends a beefier 12V 5A power-supply: ![PSU](./pix/psu.png) Since this is basically a NAS build, I opted to house all of this in: ![NAS Case](./pix/case.png) +![NAS Case](./pix/case.jpg) Which comes included with a fan, and the SATA power-cables. -- cgit v1.2.3 From 56fc00068916f1a809f5bea38105f394248348f9 Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Wed, 4 Jan 2023 15:28:15 -0500 Subject: mroe --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index ab1c350..e7785b9 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ There are many cheap VPS providers out there. I use Racknerd now. I have used Vu > The equipment I use reflect my current priorities and have changed since this project started and will continue to change in the future. +#### NAS Equipment A [ROCKPro64](https://wiki.pine64.org/wiki/ROCKPro64) 4G model. Alternatively, an RPi4 or similar would also work if you can get your hands on it. ![ROCKPro64](./pix/board.png) @@ -92,10 +93,11 @@ Since this is basically a NAS build, I opted to house all of this in: Which comes included with a fan, and the SATA power-cables. -Optional, but recommended: an external usb SSD or HDD as a backup drive. +#### Backup Equipment +An external USB SSD or HDD as a backup drive. -An finally, a very cheap VPS (Virtual Private Server) - I use Racknerd. -This will give you access to a reliable static IP. +#### VPS +A VPS (Virtual Private Server) - I use Racknerd. This will give you access to a reliable static IP. ### Base Image setup I have switched to using DietPi images (from Alpine) as they support my hardware, as well as RPis. -- cgit v1.2.3 From 1f256dd208e40468a90a51684a940631d07a67d4 Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Wed, 4 Jan 2023 15:32:24 -0500 Subject: more --- README.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index e7785b9..7c87902 100644 --- a/README.md +++ b/README.md @@ -100,12 +100,14 @@ An external USB SSD or HDD as a backup drive. A VPS (Virtual Private Server) - I use Racknerd. This will give you access to a reliable static IP. ### Base Image setup +Once you have a server+storage, and a VPS, you are ready to start. I have switched to using DietPi images (from Alpine) as they support my hardware, as well as RPis. 1. Follow instructions from [DietPi wiki](https://dietpi.com/docs/install/) to create a bootable SD card and boot up. 2. On first boot, I recommend you change your `root` password, and change the SSH server to use OpenSSH (from Dropbear). This makes running automation against it easier. 3. Then you can run our playbook with the `base` tag to install all pre-requisite software. +See the Install section below for getting started with running playbooks from this repo. 4. You should then setup your drives according to your needs. If you are doing ZFS, the section below might be useful. ### NAS Setup -- cgit v1.2.3 From 8aef00bd35d4c84b98ba51e08ad9f4e8f6e58547 Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Wed, 4 Jan 2023 15:41:11 -0500 Subject: more --- README.md | 1 + 1 file changed, 1 insertion(+) (limited to 'README.md') diff --git a/README.md b/README.md index 7c87902..989c930 100644 --- a/README.md +++ b/README.md @@ -246,3 +246,4 @@ echo "-------Backup ended-------" ## Why self-host? You can read more about my thoughts on why we should self-host on my [website](https://kumardamani.net). +If this repo has helped you, consider [sending](https://kumardamani.net/#donate) a coffee my way! -- cgit v1.2.3 From 4352c2b692b66119acd1155f150cd3071eb11310 Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Wed, 4 Jan 2023 15:46:49 -0500 Subject: more --- README.md | 1 + 1 file changed, 1 insertion(+) (limited to 'README.md') diff --git a/README.md b/README.md index 989c930..73aad73 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ This makes running automation against it easier. 3. Then you can run our playbook with the `base` tag to install all pre-requisite software. See the Install section below for getting started with running playbooks from this repo. 4. You should then setup your drives according to your needs. If you are doing ZFS, the section below might be useful. +4. Then see the Deploy section below to start deploying your apps! ### NAS Setup I recommend setting up the two drives as a ZFS mirrored pool. -- cgit v1.2.3