This is the 5th post in the "Setting up home NAS" series. Below are the previous posts. It is not required to read previous posts to understand this. But that gives some background on this series.
Setting up home NAS - Patt 4 - Raspberry Pi to build locally redundant NAS for home (This post)
If you are able to afford a prebuilt NAS device better go with that. This requires effort.
Introduction
I was running below model for the home NAS system. My main contributor is the video category. My DJI Osmo Pocket produces high-bitrate videos. Also the RAWs.
- Primary
- A router attached USB drive working as NAS. \\192.168.1.1\share. It is of 1TB capacity
- Sync the files to my personal computer that has a 500GB drive. So effectively getting only 500GB which are backed up. SyncToy is working fine for on-demand sync
- Secondary (after publishing to YouTube)
- Combine all the raw videos to single and upload to YouTube in private visibility
- One back up to another external disk that has 2TB.
- That means during editing time, 2 copies are in the router attached USB drive and personal laptop. After publishing, one uploaded to YouTube and the other copy in the different 2 TB hard disk.
As the COVID-19 pandemic slowed down and places got opened, I got chances to visit more places. Meaning more files to primary storage. One trip brings close to 10Gigs. The 500GB limit is almost reached its 3/4th capacity.
Problem
All my previous posts were explaining a problem and a solution. Every time a new problem. This time it is again going to reach the capacity and I had to do something to increase NAS storage space. As always I need two copies of files to be kept. Not an enterprise-grade NAS.
Requirement
This time I did some requirement engineering. Its nothing but looking at the past on how much data I was generating and forecasted how much more I would be in
Below are some facts I could see
- After I bought DJI Osmo Pocket there are a lot of videos coming out from trips
- One trip produce 10GB on average
- There are around 1.5 trips avg we are making per month. ~15GB
- We shoot some videos at home as well. 2.5-3 GB
- Adding the above + a buffer of 2GB ~ 20GB per month ~ 240GB/year ~ 1200GB/ 1.2TB for 5 years
- Buffer is required for technical video downloads and anything which may come on our way.
- There have to be 2 copies resulting in 2,400 GBs. But once published one backup is in YouTube itself with visibility private. So the final requirement is 1.8TB
There can be 2 systems similar to what I have now. Once published the videos can be moved to secondary.
Options
Is it time to think big or just add more drives? My YouTube channels are still in it's infancy. No hope to get monetized in the near future. The google ads revenue from Blogs is just enough to renew the
https://joymononline.in site.
If I spend more and I lose interest in YouTubing, there will be trips but just photos coming out from those. Photos can easily be stored in 2 places by using Google Photos and one hard drive.
Currently, I have one more 1TB internal hard disk which is taken from the personal laptop when it was upgraded to SSD. Total of 1 TB hard disks x2, 2 TB hard disk x 1, and 500 GB on a personal laptop.
Below are the options I could find
- RaspberryPi 4 or a similar low-powered device. Connect 1 TB hard drives to it and use as primary. Secondary continue as it
- Dedicated NAS device.
- Build a server machine by sourcing refurbished parts.
- Store in the cloud. OneDrive/Google drive etc...
If the budget is not a constraint, I would be going with the cloud option only.
Solution
Finally decided to go with RaspberryPi 4. Below are the rationale
- Its low power
- It can be used for something else
- If I lose interest in Youtubing which reduces the data generation.
- If the OneDrive or Google Drive drastically reduce their price for me to afford for 2TB.
- If our total family income increases and gets more budget to tech things cloud storage would be affordable. Yes, we do some family budgeting on the expenses. It is a big topic on its own
- I am already planning to learn Linux and would like to learn the shell way. Why don't I learn with my own problems?
- To advance my career, I would like to learn more about enterprise IT concerns. Dealing with my own problems would be a good starting point
- Obviously, my requirement of 1.8TB for the next 5 years can be satisfied with this setup. The only problem would be the slow publishing of videos which causes more videos to stay in primary storage which has only 1TB capacity.
The architecture would be similar to what I am using now
- Primary storage
- 1TB connected to RPi, expose as \\SMB shared path
- Backup 1TB attached to the router.
- Daily sync RPi connected the drive to the router attached one
- We will be seeing why can't I just connect 2 HDDs to RPi 4 which has 2 USB 3 ports
- Secondary
Home NAS using Raspberry Pi
Finally, we are discussing the business. Let us see what are the decisions, steps and issues faced.
Decisions
There are some decisions to be made
Size of RPi
The RPi 4 comes in different sizes based on the RAM. Many users say it requires only 2 GB to run as NAS. 8GB would definitely be overkill. So settled on 4GB RPi
Powered USB Hub
This is more electrical than setting up something. The very basic is any electrical equipment needs a power source. When we connect the hard disk to RasPi via a USB port, the power source of the HDD is RasPi. If RasPi cannot provide enough power to the HDD, it cannot function normally. We know the voltage is 5V but that is not all. We need to understand the maximum Watt requirement of HDD during its operation. Rotational Disk-based HDD requires the highest power to start spinning up. RasPi should be able to give that power though it may require less power during operation. In order to connect the dots, we need to consider the current as well which is measured in Amperes often noted in devices using either A or Amps or mA (milli Amps). Below is the relation that we learned in school.
W = VA
or
W=V*A (just for developers)
If one device specify W and V and another device specify V and A we can kind of do this calculation to see whether they match up
Specs
It's time to read specs that nobody likes.
RasPi specs say all 4 USB devices can together draw 1.2A of current. We know the voltage is 5V. So the max Power that can be given out through all the USB ports is 1.2 * 5V = 6W
In my case, I have 2.5" a laptop drive which has a requirement of 1.2Amps during spin up and an operational requirement of .8Amps. Meaning I can connect only one HDD to the RasPi directly at a time without an external power source. If I need to connect both the HDDs to RasPi, I would require a USB hub that has its own power source. Or buy another external HDD that is powered by a separate adapter.
This is the reason why I had to still connect my backup HDD of primary storage to the router. The router has enough power to drive HDD.
RPi OS
There are many operating systems available for RasPi. Even we can have Windows using its IoT Core edition. But decided to go with Raspberry Pi OS (Rasbian) as that is targeted to this device.
HDD FileSytem
Prefer to go with NTFS than Linux native Ext format. The main reason is in case RasPi fails I can connect the HDDs to my personal windows laptop. Planning to slowly migrate to Linux by starting with USB Linux installation with persistence storage.
Sync method
Our aim is to have one HDD connected to RasPi and another HDD to router and sync them. One more decision to be made is how to sync these 2 HDDs. There are 2 options I could find though they are not for solving the same issue and mutually exclusive.
There are already articles available on how to set up.
Here is one good article on the same. I don't recommend this approach as this is mirroring. As soon as we do a change, it's replicated. No way to get the old copy in case we accidentally delete something.
These steps are mainly based on the article above in the RSYNC section. But there are some additional steps. Only the deviations and issues faced are documented rest of this article. Better to read the above article before reading further.
Let us start with something, not in that article.