In an era where a single photo can be over 10MB and a video several GB, phone storage fills up quickly. Even a personal computer with one or two TB of storage seems insufficient. While cloud storage can hold some data, the monthly fees can be a bit painful.
Today, we will introduce how to build a home storage system with a capacity of dozens of TB using a Raspberry Pi and a hard drive enclosure, which we call a home NAS. Of course, if you have enough money and are not interested in technology, you can directly buy a mature NAS product, which is widely available online, and we won’t elaborate on that here. The entire hardware architecture is quite simple, consisting of a Raspberry Pi motherboard connected to a hard drive enclosure via USB.
The hardware is quite simple, and once set up, the software is very user-friendly and not at all shabby. Let’s take a look at a screenshot of the management interface after successful setup. Doesn’t it look professional!
This article is written for those who love to tinker and want to save some money. First, we need a Raspberry Pi, which is a microcomputer, a computer without even a cooling fan for the CPU, as shown in the picture below. Of course, we can also buy a case or a cooling fan to make it look more like a computer.
You can observe this microcomputer; the CPU and memory cannot be accessed directly. Additionally, it has common network ports, USB ports, and HDMI interfaces. Therefore, we can expand storage through the USB interface and access the storage resources through the network port.
Next, we need to expand the storage capacity by purchasing a USB 3.0 interface hard drive enclosure. For example, the five-bay hard drive enclosure shown below. By connecting it to the Raspberry Pi via USB, we can see five hard drives. If we purchase five 8TB hard drives, we will have a storage capacity of 40TB. This capacity can store tens of thousands of movies, hundreds of thousands of songs, or millions of photos. Thus, it should be sufficient for an average family for decades.
It is important to note that hard drive enclosures come in versions with and without RAID. The RAID version is more expensive, while the non-RAID version is cheaper, so choose according to your needs. Even if you choose the non-RAID version, it’s okay; we will introduce how to implement RAID functionality using software from the Raspberry Pi operating system later.
Some people may not know what RAID is, so let’s briefly introduce it. RAID is a technology that ensures data reliability by using data redundancy techniques to guarantee that data is not lost even in the event of a hard drive failure. There are many levels of RAID; the simplest, RAID 1, uses two or more drives to store the same data, so if one drive fails, data can still be accessed through the other drives. Additionally, the most commonly used RAID 5 and RAID 6 can ensure data reliability through parity data. For a detailed introduction to RAID, you can read other articles from this account; we will not elaborate on it here.
Once we have the hardware, we can prepare the software. First, we need to install an operating system on the Raspberry Pi. We can install the official Raspberry Pi operating system or install an Ubuntu operating system ourselves. We can even install an open-source NAS operating system, such as TrueNAS, RockStor, or OMV (OpenMediaVault), etc. Here, we will use the official Raspberry Pi operating system (you can search and download it yourself) as an example.
The Raspberry Pi’s operating system is installed on an SD card, so we first need to download a burning tool; here we choose the official Raspberry Pi burning tool (you can also use Etcher). The interface after starting the software is shown in the figure below (the interface may vary slightly by version, please pay attention to the version number), and you can see three buttons: the operating system image button, the SD card selection button, and the burn button.
The specific operation is very simple, and we won’t elaborate on it here. Once the selection is complete, do not rush to operate; we need to configure remote login for future operations. The specific method is to click the little gear in the figure below.
This will pop up a dialog box where we can make advanced settings through this dialog box. Here, we mainly enable remote login, which is the SSH service.
At this point, we can start burning the operating system. Once the burning is complete, we can insert the SD card into the Raspberry Pi’s slot and then power it on. Once the operating system starts, we can log in to the Raspberry Pi using SSH tools.
Next, we can install NAS services. There are two ways to install NAS services: one is to install NFS and Samba services through the command line and export the related services. The other is to install packaged NAS service software, such as OpenMediaVault. To lower the threshold, we will use OpenMediaVault as an example. You can start the installation process with the following command:
sudo wget -O – https://github.com/OpenMediaVault-Plugin-Developers/installScript/raw/master/install | sudo bash
After pressing Enter, you can see the entire installation process on the shell, which may take a while. The final successful installation output is shown below, and you can see that we installed a total of 92 software packages.
After successful installation, you can log in to the system via the web. The figure below shows the configured dashboard page, which may differ slightly for new systems. The main functions are concentrated in the left navigation bar, and we mainly focus on the content related to storage, involving the storage and service tabs in the navigation bar.
Account: admin
Password: openmediavault
Clicking on “Storage” opens that tab, where you can see sub-tabs including disks, SMART, soft RAID, file systems, and shared file systems. When clicking on “Disks,” you can see all the hard drives in the system, and we have a total of six hard drives as shown in the figure below.
Another important aspect is the content in the “Services” tab. Clicking on it shows the following content. You can see common services like NFS, SMB, and SSH. Among them, NFS and SMB are services used for file sharing between computers, which is what we call NAS services.
After understanding the above functions, we will next introduce how to configure them. This mainly involves two aspects: configuring storage resources and configuring service-related content so that other computers (or phones) can access the storage resources.
For storage resources, the lowest level is a single hard drive, which can be bundled into a virtual hard drive through soft RAID. This virtual hard drive can ensure data reliability through RAID algorithms (as mentioned earlier). Additionally, a file system must be created on this virtual hard drive to be exported by NFS or SMB services. First, we need to build RAID based on the hard drives. By clicking on the “Soft RAID” tab, you can see a create button (plus sign), which will bring up a wizard that we just need to follow.
It is important to note that after completing the wizard, the configuration does not take effect. During the process, a warning message may appear, as shown in the figure below, and we need to click the checkmark on the right to apply the configuration. All subsequent configurations will follow this principle, so please pay attention.
After creating the RAID, we need to create a file system on this RAID. By clicking on the “File Systems” tab, you can see the relevant function buttons as shown in the figure below. Clicking the plus sign will bring up a wizard to create a file system, and you can follow the wizard, which is quite simple, and we won’t elaborate on it here.
Once the file system is created, we can click on “Shared Folders” to create shared folder resources. Essentially, this wizard creates a subdirectory in the root directory of the previous file system and sets permissions.
After the above steps, we have created exportable storage resources. Next, we need to start the services. Taking NFS service as an example, it includes two settings: “Settings” and “Sharing.” “Settings” is used to configure the type of NFS service to start. “Sharing” is used to export the shared directory created earlier. If you are familiar with NFS in Linux, this step is essentially adding a configuration item to the /etc/exports file.
The above figure shows the wizard for “Sharing” configuration, where it should be noted that you need to fill in the client’s IP address, which specifies which clients are allowed to access the current NFS service. After completing the configuration, we can access it from another client. This client can be another computer or a phone.
Related Articles
The dilemma of tens of thousands of clients with NFS service, discussing automatic mounting technology. Why is it said that NFS read/write performance is poor, and how to optimize it? NFS protocol end-to-end instance analysis of the write data flow. NFS protocol end-to-end instance analysis of the file lock flow. Linux NFSD software architecture and code analysis. The architecture and practical use of Ceph’s file system. Software architecture and case analysis of distributed storage. What is a file system, taking Linux’s Ext4 as an example? Object storage, from single machine to distributed evolution. What is cloud storage, starting from object storage?
Leave a Comment
Your email address will not be published. Required fields are marked *