Why I built this

I wanted a place to back up my lab machines without buying a commercial NAS. Everything in this build is free and open source, and I tried to spend as little as possible.

I followed this YouTube tutorial for the overall approach. It used NTFS and several drives, and I changed it to fit what I had: one drive, btrfs, and a Samba share. The tutorial is great, but a few of its steps didn’t apply to my setup, and that’s part of the story below.

What I used, and what it cost

ItemCost (UGX)
Raspberry Pi 2B0 (from a colleague)
Toshiba 1 TB 2.5" laptop hard drive (after bargaining)130,000
Haysenser dual-bay HDD docking station, with its own power adapter110,000
SD card, power supply, Ethernet cable0 (already owned)
Total spent240,000

Why a Pi 2B? In Uganda I could only find a Pi 4 or newer, at about 385,000 UGX for the board alone. Buying that new would have pushed the total to about 625,000 UGX. A colleague had a Pi 2B, so I used it. It’s slower, but for scheduled backups it’s good enough.

The rest of the setup relies on infrastructure I already had: the router, the cables, the SD card and a power supply.

The Pi 2B, the Haysenser dock with the Toshiba drive, and my router

The whole setup: the Pi sits on my fibre router and plugs straight into it with an Ethernet cable. The Toshiba drive sits in the dock beside it, which has its own power. (I covered the drive’s serial number, QR code and shop stickers.)

The limits of a Pi 2B

  • USB 2.0 only, so the dock can’t run at full speed
  • 100 Mbps Ethernet, so expect roughly 8 to 11 MB/s
  • 32-bit, which limits which NAS software runs on it

For nightly backups that’s fine. For a first big copy, it’s slow.

Why a docking station?

A dock holds a bare drive and powers it from its own adapter. That means the Pi’s USB port only carries data, so there are no under-power disconnects, and I can swap drives without opening anything. Mine is a Haysenser dual-bay dock that takes both 2.5" and 3.5" drives, so it can also hold a bigger drive later.

Before I bought this, I looked at a listing for a 3.5" SAS drive. It would never have worked: the Pi has no SAS support, and a 3.5" drive needs its own 12V power. A 2.5" SATA laptop drive in a dock is the easy route.

Step 1: Install the OS

I flashed Raspberry Pi OS Lite (32-bit) with Raspberry Pi Imager, set the hostname to Nas, enabled SSH and created a user. The Pi 2B has no Wi-Fi, so it needs a cable.

After the first boot I logged in over SSH and updated everything:

sudo apt update && sudo apt full-upgrade -y

SSH login to the Pi

Step 2: Find the drive

I connected the dock to the Pi and ran lsblk. Before touching anything, I confirmed which device was which:

  • sda (931.5G) was the Toshiba drive in the dock
  • mmcblk0 (59.5G) was the SD card

The drive already had two partitions from Windows, which is why I double-checked. Formatting the wrong device would have wiped the OS.

lsblk showing the 1 TB drive and the SD card

Step 3: NTFS or btrfs?

The tutorial used NTFS. NTFS has one big advantage: if the Pi dies, I can plug the drive into any Windows PC. I chose btrfs instead, for its checksums, which detect silent corruption, and for its better behaviour after power cuts.

The trade-offs I accepted:

  • Windows can’t read btrfs natively, so recovery means a Linux live USB or the WinBtrfs driver
  • On a single drive, btrfs can detect corruption but can’t repair data
  • A single drive is still not a safety net

Step 4: Partition, format, mount

sudo parted /dev/sda --script mklabel gpt mkpart primary btrfs 0% 100%
sudo mkfs.btrfs -f -L nasbackup /dev/sda1
sudo mkdir -p /mnt/nas
sudo blkid /dev/sda1

One partition after repartitioning

mkfs.btrfs output with the label and UUID

Then I added this line to /etc/fstab, using the UUID from blkid (not the UUID_SUB value):

UUID=<your-uuid>  /mnt/nas  btrfs  defaults,noatime,nofail  0  0

nofail means the Pi still boots if the dock is off or unplugged. This matters with a dock: switch the dock on before the Pi boots, or the drive won’t mount.

df -h /mnt/nas showed 932G, so the mount worked:

df showing 932G mounted at /mnt/nas

Step 5: A dedicated backup user

I didn’t want to hand out my admin account, so I created a user that can’t log in to the Pi and only exists for the share:

sudo adduser --disabled-password --gecos "" nasuserqk
sudo smbpasswd -a nasuserqk
sudo chown -R nasuserqk:nasuserqk /mnt/nas
sudo chmod 775 /mnt/nas

Creating the backup user

Ownership of /mnt/nas

Mistakes I made here

  1. Capital letters. I first typed nasuserQK. Linux said invalid user, so I made it lowercase.
  2. Running smbpasswd with no arguments. It asked for an “old SMB password” because it was trying to change my password. The correct command is sudo smbpasswd -a <username>.
  3. Copying the tutorial blindly. It used NTFS mount options (uid=, gid=) that btrfs doesn’t use. With btrfs, chown does that job. I also skipped its four-drive folders and its rsync mirroring, since I only have one drive.

Step 6: The Samba share

I added this to the bottom of /etc/samba/smb.conf:

[nasbackup]
   path = /mnt/nas
   browseable = yes
   read only = no
   valid users = nasuserqk
   force user = nasuserqk
   create mask = 0664
   directory mask = 0775

Then I ran testparm -s and restarted Samba with sudo systemctl restart smbd.

Step 7: Connecting from Windows (where it got interesting)

My PC is joined to my lab’s Active Directory domain, so Windows tried to log in as DOMAIN\... instead of as a local account on the Pi. I had also typed the username wrong. The fix was to use Nas\nasuserqk (or .\nasuserqk) as the username.

Windows prompting for credentials with a domain prefix

Then copying a file failed with “Destination Folder Access Denied”. The clue was in the dialog: total size 58 GB. My drive is 932 GB, and 58 GB is the size of the SD card.

Access denied, with a total size of 58 GB

I had mapped the wrong share. Windows labels a mapped drive with the share’s name, and mine said nasuserqk, not nasbackup. The 58 GB size gave it away: that was the SD card, not my 1 TB drive:

The mapped drive N: showing 58 GB, the SD card

The fix was to disconnect it and map the correct share:

net use N: /delete
net use N: \\<pi-ip>\nasbackup /user:Nas\nasuserqk /persistent:yes

Windows then showed nasbackup with 931 GB total. That’s the Toshiba drive:

The corrected drive N: showing 931 GB, the real HDD

Lesson: after connecting to any NAS, check the total size before you copy anything. If the size doesn’t match your drive, you’re in the wrong place.

Step 8: Does it work?

Yes. With the correct share mapped, Windows shows nasbackup with 931 GB total and 929 GB free. That’s the Toshiba drive, so backups land on the 1 TB disk and not on the SD card.

I haven’t benchmarked it. On the Pi 2B’s 100 Mbps Ethernet, expect roughly 8 to 11 MB/s, which is fine for scheduled backups and slow for a first big copy. To keep an eye on the drive, sudo btrfs scrub start /mnt/nas checks the data checksums, and sudo smartctl -a -d sat /dev/sda reads the drive’s health data through the dock (some docks don’t pass it through).

What I’d do differently

  • Use a Pi 4 or 5 if the price allowed, for gigabit Ethernet and USB 3.0
  • Add a second drive (the dock makes swapping easy) or an offsite copy, because one disk is not a backup strategy
  • Set up btrfs snapshots to protect against accidental deletes
  • Join the Pi to my Samba AD domain, so people log in with their own accounts instead of a shared password

Final thoughts

The whole thing cost 240,000 UGX, and the most expensive part was the drive. It isn’t fast and it isn’t fancy, but it gives me a second copy of my lab data on hardware I control. If you’re in Uganda and a new Pi at 385,000 UGX is out of reach, ask around for an old board. Mine came from a colleague’s drawer.