PiNAS

I would like to share my latest creation. PiNAS is and attempt at making small home server based on Raspberry Pi 3B+.

Main components:

  • Raspberry Pi 3 Model B+
  • Raspberry Pi Universal Power Supply 5.1V 2.5 A
  • Ultra-thin Aluminum Alloy CNC Case Portable Box Support GPIO Ribbon Cable For Raspberry Pi 3 Model B+(Plus)
  • WD Elements 2.5” USB 3.0 4 TB
  • SanDisk Ultra microSDHC UHS-I 16 GB

Raspbian Stretch Lite is the choice of OS.

The easiest and clean way I’ve found to transfer the root partition from the SD card to the HDD: How to Boot Raspberry Pi from USB Hard Drive

Previously I’ve used 3B and had no problems booting from the USB HDD. 3B+ is a different animal. I’ve spent hours researching why it did not booted directly from the HDD. Finally came across this article: Raspberry Pi boot modes

So I have to keep the SD card with fresh bootcod.bin on it at boot time. Afterword’s the card is not used as my root partition is located on the USB HDD.

I’ve tried this first: How to boot from a USB mass storage device on a Raspberry Pi but it did not work! Than this: Raspberry Pi 3 USB booting
No Luck!

In this article it is explained Why in a very detailed manner: Pi 3 booting part I: USB mass storage boot beta

After that everything works as expected. Now on boot Pi reads the boot partition from the SD card and continues from the HDD.
In contrast my 3B just reads everything from the HDD and there is not SD card needed.

Now is time to install Docker and Docker-Compose: How to run docker and docker-compose on Raspbian

Note this is my first 3B+ model. Previously I’ve used 3B and had no problems booting from the USB HDD. 3B+ is a different animal. I’ve spent hours researching why it did booted directly from the HDD. Finally came across this article: Raspberry Pi boot modes

So I have to keep the SD card with fresh bootcod.bin on it at boot time. Afterword’s the card is not used as my root partition is located on the USB HDD.
I’ve tried this first: How to boot from a USB mass storage device on a Raspberry Pi but it did not work! Than this: Raspberry Pi 3 USB booting No Luck!
In this article it is explained why in a very detailed way: Pi 3 booting part I: USB mass storage boot beta

After that everything works as expected. Now on boot Pi reads the boot partition from the SD card and continues from the HDD.
In contrast my 3B just reads everything from the HDD and there is not SD card needed.

Now is time to install Docker and Docker-Compose: How to run docker and docker-compose on Raspbian

Adding Samba and Deluge was quick and easy.

As inspiration of this build and post I would like to tank to the creators of the following posts:
Raspberry Pi Home Server – really liked the UPS and Dynamic Fan Control.
Create a hardened Raspberry Pi NAS – some of the configurations came quite in handy.

PiNAS 2.0
As you know Raspberry Pi 4B was announced last week. It will provide 4 GB RAM, Real Gigabit Ethernet and 2 USB 3.0 Ports. Hope I’ll be able to attach two USB 3.0 HDDs and maybe build a software RAID.  For the moment I’ll have to wait as even USB HDD Boot is not implemented in Raspbian Buster. With a bit of luck in a couple of months all will be fixed and working.

Until then my setup provides almost 20 MB/s throughput over Samba.

My blog new home

Introduction
Hello everyone. I’ve been running this blog for 9 years now. In 2010 there were very few options to host WordPress site. The blog was hosted in one local provider up until its acquisition by another company two years ago. This pushed me to move. At that time, I was experimenting with Azure and the natural choice of service was an Azure Web App with WordPress template.


The platform is packed with settings that you can tweak. Unfortunately, the prices are targeted at enterprise customers and were too steep for a small site like mine.
Recently a friend of mine mentioned the Static Site Generators. I’ve investigated the topic and it appeared quite an interesting concept. For my purposes this solution fits well as most of my content is static. Thanks to GDPR I had to close all comments and feedback options, which made the site even more static. On the positive side not having to worry about PHP and MySQL out in the wild sounds very a pleasing.

Static Site Generators Research
After reviewing a couple of solutions, the idea to use WordPress as a Static Site Generators begin to take shape. This could be achieved by employing Plugins. The ones that I’m currently experimenting with are:
Simply Static
WP2Static
Each has some very strong features. But I still haven’t decided which one to keep.
Simply Static has great Diagnostics that helped me troubleshoot some issues. Offering streamlined interface with essential options. While WP2Static gives more control over the crawling and processing with valuable options to clean up some garbage from the output pages.
They both produced archives containing the static content, WP2Static can even be configured to push it directly to GitHub repository.

Web Hosting
Either way I have a static version of my site now. The next hurdle is where to store the files?
I don’t want to host it On-Premise as this will require a lot of additional time and effort. As the Cloud options are so many, let’s narrow it down to Static Websites on Azure Storage and GitHub for simplicity sake.
Ever since I’ve read about the Static Websites in Azure, I really wanted to try it with something. Now having the content experiments can commence. My inspiration came from this article Static websites on Azure Storage now generally available
Price for storing content and data transfers charges would be low in my case. SSL is requirement but it is not directly offered from Static Websites. I need Azure CDN in front to get the desired feature. This will incur additional cost and complexity for just one simple static site served over HTTPs.
For Web Apps there is a Azure Let’s Encrypt Extension that is a pretty useful solution to automatically renew the SSL Certificate.

This tilted the table in favour of GitHub. There are no taxes for storing publicly accessible content and it automatically takes care of the SSL Certificate provisioning and renewal. For the moment GitHub wins.

WordPress Hosting
Now that I have the generation and web hosting covered. The last obstacle is where to keep my Static Content Generating WordPress instance?

Cloud:
WordPress.com – good starting point. But pretty much the same. You get a free WordPress instance somewhere out there. Not my ideal solution.

Azure Containers Instance – recently I have experiment with this service. It is perfectly suited to quickly get up and running a bunch of containers. Get the job done and destroy them. There is a ready-made template to build two containers solution for WordPress here: Create a WordPress site on a Container Instance
My experience with the service is mostly positive. Bringing it up is easy. Getting data persistence requires modifying the template. The performance at the lowest tire was comparable to the once in Web App and insufficient from my perspective.

Local:
VM with docker containers – My first choice. Spun up Ubuntu server, quickly and easily installed docker and docker compose. As I felt generous at the time the VM had 4 CPU cores and 4 GB or RAM. Even on mechanical HDD, performance was Fantastic! I never knew that WordPress could feel so snappy! The downside is that I will not keep the VM running all the time and must start and stop it every time that I want to do something.














RPI with docker containers – As I have a Raspberry Pi humming in the background. This is a preferable alternative to a full blown VM. I’ve managed to install docker and docker compose relatively easy using as a starting point this article: The easy way to set up Docker on a Raspberry Pi and HOW TO RUN DOCKER AND DOCKER-COMPOSE ON RASPBIAN

To my unpleasant surprise there is NO official MySQL image for ARM, Really!? Check this article: Install mysql server-5.7 on ARMv8 architecture (raspberry pi 3 model B)
But there is one for WordPress. I’ve tried building one on my own and hit a lot of problems! As a temporary solution for the moment I’m using this image hypriot/rpi-mysql. Works fine but holds MySQL 5.5 and my aim is 5.7. In near future I’ll look into it and if possible, build one image on my own.
Had a few hiccups with the persistent storage of data for both WordPress and MySQL containers, but got it right at the end.
Here is the content of my docker-compose file:

version: '3.7'

services:
   db:
     image: hypriot/rpi-mysql:latest
     volumes:
       - ./db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: [ROOTPASSWORD]
       MYSQL_DATABASE: [DBNAME]
       MYSQL_USER: [DBUSER]
       MYSQL_PASSWORD: [DBPASSWORD]

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     volumes:
      - ./wp-content:/var/www/html:rw
     ports:
       - "80:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_NAME: [DBNAME]
       WORDPRESS_DB_USER: [DBUSER]
       WORDPRESS_DB_PASSWORD: [DBPASSWORD]

volumes:
    db_data: {}
    wp-content: {}

Again, the performance is even more surprisingly good compared the cloud scenarios. Considering that it is run off a mechanical hard drive on a very humble 1.2GHz Quad and only 1 GB of RAM.

Conclusion
With this exercise I’ve managed to decrease the costs of hosting this blog to the bare minimum. Hosting costs are reduced to virtually free. The power costs for the Raspberry Pi are shared with other services and are negligible.
Compared with Azure Web App and it’s 20 Euros per month it is a feat!
My initial intention for this post was to be short and sweet, but it grew into something much larger. I was able to compress a few weeks of research and experiments into these few lines omitting a lot of problems crossed along the way. Hope you enjoy reading it.