A network-attached storage (NAS) system can be a great addition to your computing setup if you want a centralized storage solution. Modern-day NAS setups support multiple RAID levels, immutable snapshots, and a wide array (pun intended) of failsafes to ensure that your data remains secure. Plus, you can use them to share files across your devices.

While a NAS may sound like a pricey investment costing thousands of dollars, it’s not really all that expensive. If you don’t mind (relatively) slow read and write speeds, you can build a cheap NAS for under $100 using a Raspberry Pi.

What you’ll need

Since the entire NAS project revolves around a Raspberry Pi, you'll need one of these palm-sized single-board computers. I'll be using a Raspberry Pi 5 for this guide, but you can do this on older boards, too. However, if you pick anything older than the Raspberry Pi 4b, the NAS will get bottlenecked by the slow transfer rates of USB 2.0 ports.

You’ll also need a microSD card to boot into the operating system powering the NAS. If you want your NAS to be responsive, you should grab a fast microSD card with at least 4GB capacity.

Finally, you need a storage drive to store all the data. Here’s the twist: Unlike typical NAS, Raspberry Pi boards lack SATA slots and instead rely on USB ports to access an external storage device. Depending on your requirements and budget, you can choose a high-capacity hard drive or a cheap flash drive.

  • A render of the Raspberry Pi 5
    CPU
    Arm Cortex-A76 (quad-core, 2.4GHz)
    Memory
    Up to 8GB LPDDR4X SDRAM
    Operating System
    Raspberry Pi OS (official)
    Ports
    2× USB 3.0, 2× USB 2.0, Ethernet, 2x micro HDMI, 2× 4-lane MIPI transceivers, PCIe Gen 2.0 interface, USB-C, 40-pin GPIO header
    GPU
    VideoCore VII
    Starting Price
    $60

  • A render showing a PNY Elite mircoSDHC card in green and grey color.

  • SanDisk iXpand Flash Drive Luxe showing off the USB Type C port and Lightning port

Flashing the operating system

Once you have the necessary components, it’s time to flash an OS onto the microSD card. I’ll be using the Raspberry Pi OS Lite since a headless setup will improve the performance of the NAS, but you can also pick the GUI version. I'm using the official Raspberry Pi Imager, which provides the option to enable SSH and WLAN without going through the trouble of creating additional files on the microSD card.

  1. Download the Raspberry Pi Imager from the official link.
  2. Click on the Install button after running the Imager.exe tool with admin privileges.
  3. Once the tool has finished installing, run rpi-imager.exe as an administrator
  4. Click on Choose Device and pick your Raspberry Pi model.
    A screenshot of Raspberry Pi Imager highlighting the steps to choose a device
  5. Select Choose OS and click on Raspberry Pi OS (other).
    A screenshot of Raspberry Pi Imager highlighting the steps to choose an OS
  6. Select Raspberry Pi OS Lite (64-bit).
    A screenshot of Raspberry Pi Imager highlighting the steps to select the Raspberry Pi OS Lite
  7. Click on Choose Storage and select the microSD card you want to use as the boot device for the Raspberry Pi.
    A screenshot of Raspberry Pi Imager highlighting the steps to choose a storage device
  8. Press Next and choose Edit settings on the pop-up window.
    A screenshot of Raspberry Pi Imager highlighting the steps to edit the OS settings
  9. Type the username and password.
    A screenshot of Raspberry Pi Imager highlighting the steps to enter the username and password
  10. (Optional) If you want to access the Raspberry Pi over Wi-Fi, enable the Configure wireless LAN checkbox and enter the network SSID, password, and location.
    A screenshot of Raspberry Pi Imager highlighting the steps to configure the WLAN settings
  11. Navigate to the Services header, check the box adjacent to Enable SSH, and click on the Save button.
    A screenshot of Raspberry Pi Imager highlighting the steps to configure SSH
  12. Choose Yes twice and wait for the tool to finish writing the OS files.

When I tried to create a NAS with a Raspberry Pi 3b last year, I installed OpenVaultMedia (OVM), which provides an intuitive GUI interface. Unfortunately, OVM 6 is only compatible with the older Buster and Bullseye versions of the Raspberry Pi OS and doesn't support the latest Bookmark release. So, we’ll have to make do with the CLI interface instead.

Checking the IP address of your Pi

You’ll need the IP address of your Raspberry Pi before you can log in from another system via the SSH command. To do so,

  1. Click on the Wi-Fi icon in the top-right corner of the screen.
  2. Select Advanced options.
  3. Choose Connection Information, and note down the IP address under the IPv4 section.
    A screenshot of the Raspberry Pi OS highlighting the procedure to check the IP address of the SBC

Connecting to the NAS

Since the NAS server will be operated in a headless setup, you’ll need to access it from another PC.

I have switched to PuTTY from here on out since it's easier to use, but the procedure is mostly the same if you're using the Terminal shell in Windows 11.

  1. Insert the microSD card and plug the power and Ethernet cables into the Raspberry Pi. If you’re using a Raspberry Pi 5, you’ll need to press the power button to turn on the SBC.
  2. Switch to another PC.
  3. Download PuTTY from this link and open the app after installing it.
  4. Type the IP address of the Raspberry Pi as the destination and make sure SSH is selected as the Connection type before clicking Open.
    A screenshot of PuTTY with the IP address of the Raspberry Pi highlighted
  5. Type the name and password of the root user to enable the SSH connection.
    A screenshot of PuTTY with the name and password of the root user highlighted

Configuring the storage drives

Next, it’s time to partition, format, and mount the storage drive for the NAS.

  1. Use the lsblk command to view the list of drives.
    A screenshot of PuTTY with lsblk command highlighted
  2. Running the following command will open the Parted tool.
    sudo parted /dev/sda
    A screenshot of PuTTY highlighting the command to open the Parted interface
  3. Type mklabel gpt and enter yes when asked for confirmation.
    A screenshot of PuTTY with the mklabel gpt command highlighted
  4. Type quit to close the Parted interface.
  5. Run the mkfs.ext4 command to format the newly created partition:
    sudo mkfs.ext4 /dev/sda1
    A screenshot of PuTTY with the mkfs.ext4 command highlighted
  6. Press Y when prompted for confirmation.
  7. Enter mkdir command to create a mount point for the drive:
    sudo mkdir /mnt/sda1
    A screenshot of PuTTY with the mkdir command highlighted
  8. Mount the drive by entering the following command:
    sudo mount /dev/sda1 /mnt/sda1
    A screenshot of PuTTY with the mount command highlighted

Setting up a Samba server

Once you’re done adding the drives, the next step is to set up a way to share them over the network. Samba is free to use and lets you share files with multiple devices, so we’ll be using that for our Raspberry Pi-powered NAS.

  1. Run the following command to install Samba on your Raspberry Pi:
    sudo apt-get install samba samba-common-bin -y
  2. Paste the following command to create a directory for Samba:
    sudo mkdir /home/samba-folder
  3. Grant read and write privileges to the file by running these commands:
    • sudo chown -R root:users /home/samba-folder
    • ​sudo chmod -R ug=rwx,o=rx /home/samba-folder
      A screenshot of PuTTY highlighting the commands to grant read and write previleges
  4. Mount the drive to the Samba directory by running the following command:
    sudo mount /dev/sda1 /home/samba-folder
    A screenshot of PuTTY highlighting the command to mount a drive to the Samba directory
  5. Execute the following command to open the fstab file:
    sudo nano /etc/fstab
    A screenshot of PuTTY highlighting the command to open the fstab file
  6. Add these lines at the end of the file:
    • /dev/sda1 /home/samba-folder auto noatime,nofail 0 0
    • /dev/sda1 /home/samba-folder vfat dmask=000,fmask=111,user 0 1
      A screenshot of the fstab file
  7. Press Ctrl + X to save the file, and press Y when prompted for confirmation.
  8. Open the Samba configuration file by entering the following command:
    sudo nano /etc/samba/smb.conf
    A screenshot of PuTTY highlighting the steps to open the Samba configuration file
  9. Scroll to the bottom of the file and paste the following lines:
    • Path = /home/samba-folder
    • Browseable = yes
    • read only = no
    • Writeable = Yes
    • only guest = no
    • create mask = 0777
    • directory mask = 0777
    • Public = yes
    • Guest ok = yes
  10. (Optional) Feel free to change nasberrypi with the name you wish to give to your NAS server. If you're the only person using the NAS, you can also add the force user command like I have in the screenshot below.
    A screenshot of the smb.conf
  11. Save the file by pressing Ctrl + X, then Y.
  12. Reboot Samba by executing the following command:
    sudo systemctl restart smbd
    A screenshot of PuTTY highlighting the command to restart Samba
  13. (Optional) Add a user by entering these commands:
    • sudo adduser nasowner
    • sudo smbpasswd -a nasowner
      Be sure to give this new user a password.

Accessing the NAS

A screenshot of Windows 11 with the Raspberry Pi NAS displayed

Finally, you can use File Explorer in Windows 11 to manage your files on the NAS:

  1. Open File Explorer.
  2. Click on the three dots in the Navigation Pane and choose Map Network Drive.
    A screenshot of Windows 11 highlighting the steps to map a network drive
  3. Pick a drive letter and enter the IP address of the Raspberry Pi, followed by the hostname you added in the sbm.conf file in the name field.
  4. Press the Finish button.
    A screenshot of Windows 11 highlighting the steps to connect to a Raspberry Pi NAS
  5. If you added a user before, enter the username and password to log in to the Raspberry Pi.

Creating a personal NAS-berry Pi server

And that's it! If you have followed all the steps correctly, the samba-folder will be open, and you’ll be able to store and retrieve all your files in the newly created NAS.

That said, a Raspberry Pi-based NAS server is unfit for large projects due to its lack of SATA connectivity and limited support for RAID configurations. If you’re looking for a powerful device to manage all your professional workloads, you should instead purchase a high-end NAS enclosure or convert an old PC into a makeshift NAS.