Building a NAS with Raspberry Pi 4: A Simple Guide to Network Storage

To not miss my updates, remember to check the public account in the upper right corner and set it as a star, take down the stars and give them to me.

Building a NAS with Raspberry Pi 4: A Simple Guide to Network Storage
Building a NAS with Raspberry Pi 4: A Simple Guide to Network Storage
Last month, we shared our treasured boards for everyone to learn and use. The first batch of users who received the boards shared their experiences with Darwin, and the first article about using Raspberry Pi 4 is below.
The trial application is still ongoing, click to view ☞☞In 2020, Darwin will sponsor your development board for the whole year.

This article content comes from Darwin fan Zhang Zhixuan‘s practical operation sharing of using Raspberry Pi 4: How to build a NAS personal file server with Raspberry Pi 4? Let’s operate together with the video below.

What is NAS?

NAS (Network Attached Storage: Network Attached Storage) literally means a device connected to the network with storage capabilities, hence also callednetwork storage. It is a dedicated data storage server. It is data-centric, completely separating storage devices from servers, centrally managing data, thereby freeing up bandwidth, improving performance, reducing total cost of ownership, and protecting investments. In short: a networked hard drive.

Why use Raspberry Pi 4 to make NAS?

The main reason is that the Raspberry Pi4 supports USB3.0 for the first time in Raspberry Pi history. Previous generations of Raspberry Pi only supported USB2.0. Not only is the speed pitiful, but there is also a serious problem: some mechanical hard drives require a certain current supply. If the current cannot support the motor of the mechanical hard drive, the hard drive will repeatedly lose power, not to mention the slow access speed, which can also damage the hard drive. Now the Raspberry Pi4 natively supports USB3.0, and by installing a SATA to USB3.0 adapter on an old hard drive, it can work with the Raspberry Pi4 to form a NAS.

Tutorial and Operation Steps

Step 1: Install Samba

Type in the command line:
sudo apt-get install samba
Let me briefly explain why to use Samba: Raspberry Pi is based on Linux, and Linux‘s file system is different from Windows‘ file system. Therefore, theoretically, files on Windows cannot be accessed on Linux, but Linux systems can access files created by Windows. If someone has used both Windows and Linux dual systems, they can observe this phenomenon:Files from Windows cannot be seen in Linux, but Linux can see Windows‘ system files. How can we allow other systems to see Linux system files? This is where Samba comes in.
Samba is essentially a bridge that reads Linux files, “translating” them into files that can be understood by other platforms, allowing remote access to Linux files.
After installation, you can use sudo samba -V to check the current version, to confirm the installation was successful.
Step 2: Check hard drive location
sudo fdisk -l
Building a NAS with Raspberry Pi 4: A Simple Guide to Network Storage
This command will list all hard drives connected to the Raspberry Pi, find the one you need.
Usually, it is/dev/sda1.
Step 3: Modify the hard drive mount location
Type:
sudo mkdir /media/Mydisk
Create a folder at /media/Mydisk,
sudo mount /dev/sda1 /media/Mydisk
Building a NAS with Raspberry Pi 4: A Simple Guide to Network Storage
This folder is the mount point for the hard drive. If you don’t understand, you can think of it as creating a shortcut to the hard drive in this folder.
Step 4: Modify the configuration file:
Type:
sudo nano /etc/samba/smb.conf

Add the following text:

[Mydisk]       comment = Mydisk       path = /media/Mydisk        writeable = yes       browseable = yes       create mask = 0755       directory mask = 0755

This describes the hard drive’s name, visibility, writability, and other parameters. To understand more, you can refer to the Samba official documentation.

Samba has rich functionalities, allowing for private or shared spaces. If you find GitHub slow and most people are working in the same local area network, you can also use Samba to save project files.

Building a NAS with Raspberry Pi 4: A Simple Guide to Network Storage

After saving, exit.
After exiting, type:
sudo samba restart

Restart the service.

In Win10, you also need to enable the SMB service:
Open Control Panel – Programs and Features – Turn Windows features on or off – Enable SMB service.
After completing, it will prompt you to restart the computer, just restart.
Final Step: Open the Run dialog and enter \raspberrypi.local to access the network folder.
If you need to shut down the Raspberry Pi, you can add a startup command:
sudo update-rc.d samba defaults
This will enable it to start automatically on boot.
If you still cannot access, you need to modify the registry file:
Win10 has removed insecure access to anonymous networks by default, and we need to enable it. This requires modifying the registry, as follows:

Open the “Run” dialog, enter: regedit, and find the following key [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters] AllowInsecureGuestAuth, (type DWORD32) and set it to “1”. If this value does not exist, just create one.

Bonus: Test the speed of the cloud disk

First, try the wireless network:

Building a NAS with Raspberry Pi 4: A Simple Guide to Network Storage

This speed is limited by the router. Under the same local area network, the access speed is still not high, but it is enough to watch 1080P, and the network delay is definitely lower than the internet. If you are sharing with roommates in the dormitory, you can connect directly to the router with an Ethernet cable.
Now try the wired network:

Building a NAS with Raspberry Pi 4: A Simple Guide to Network Storage

Because I am using a lightweight laptop, I am using a USB to Ethernet adapter, so the network card only supports 100M, hence the speed is stable at a little over 100M. The Raspberry Pi 4 uses a gigabit network card, and if your laptop also has a gigabit network card, the speed can reach that of a general mechanical hard drive.
Additionally, after setting up NAS, you can configure an offline downloader, which can automatically download in the background, allowing you to watch videos at night without buffering.
END
Building a NAS with Raspberry Pi 4: A Simple Guide to Network Storage

Darwin Project Sharing Series—— Focus on popular application technologies such as IoT, embedded systems, AI, FPGA, etc., open source sharing of schematics, code, and project solutions, making you a knowledge base at hand.

Highlights of the Project Sharing Series:

STM32 IoT Smart Home Project

Raspberry Pi + Compute Stick 2 for Real-time Face Recognition Project

Cloud Computing Platform Setup for Embedded Development Boards

STM32 Realizing the Simplest Air Mouse

Arduino Rubik’s Cube Robot

STM32 Version of “AI Soul Painter”

STM32 Electronic Photo Album Production

STM32 + DDS Homemade Signal Generator

Remote Control of Household Appliances with Raspberry Pi and Web Interface

STM32 “Cloud” Music Player

Raspberry Pi Remote Monitoring

Design of Neon Tube Clock Based on STM32

Homemade FPGA Minimum System Board (PCB can be directly manufactured)

We are Nimo, the founder of Darwin, only talking about technology and not flirting. The Darwin online education platform aims to serve professionals in the electronics industry, providing skill training videos covering popular topics in various subfields such as embedded systems, FPGA, artificial intelligence, etc. Tailored content for different groups, such as commonly used knowledge points, disassembly evaluations, electronic competitions/smart cars/postgraduate entrance examinations, etc. Welcome to follow us.

Official website: www.darwinlearns.com

Bilibili: Darwin

QQ Group: 1057755357

Building a NAS with Raspberry Pi 4: A Simple Guide to Network Storage

Building a NAS with Raspberry Pi 4: A Simple Guide to Network Storage

Leave a Comment

Your email address will not be published. Required fields are marked *