Turn a Spare 1TB HDD into a Raspberry Pi NAS: Step‑by‑Step Guide
This tutorial shows how to repurpose a 1 TB 2.5‑inch hard drive as a network‑attached storage device using a Raspberry Pi, covering hardware preparation, router MAC binding, Samba configuration, automatic NTFS mounting, and client access from Linux, Android, and Windows.
Prerequisites
Raspberry Pi with Raspberry Pi OS installed.
External 1 TB 2.5‑inch (or 3.5‑inch) HDD in a USB enclosure.
Home router for network connectivity.
Bind the Pi’s MAC address to a static IP
Log into the router’s admin interface.
Navigate to the DHCP or LAN settings.
Add a DHCP reservation using the Pi’s MAC address and the desired IP address.
To find the Pi’s MAC address, open the router’s device list or use ifconfig on the Pi.
Install and configure Samba
SSH into the Pi: ssh pi@<em>IP_ADDRESS</em> Install Samba: sudo apt-get install samba -y Edit the Samba configuration file: sudo vim /etc/samba/smb.conf Append a share definition at the end of the file:
[share]
comment = Shared folder
path = /home/pi/share_files
public = no
writable = yes
guest ok = noCreate the shared directory and Samba user
Create the directory that will be exported: mkdir -p ~/share_files Add the Linux user pi as a Samba user (you will be prompted for a password): sudo pdbedit -a -u pi Restart the Samba service to apply changes:
sudo service smbd restartMount the external HDD automatically
Connect the HDD to the Pi via USB.
Identify the partition and its UUID: sudo blkid Look for the line corresponding to /dev/sda2 (or the appropriate device) and note the UUID value.
Edit /etc/fstab to add an entry that mounts the partition at the shared directory on boot. Example entry (replace YOUR_UUID with the actual UUID):
UUID=YOUR_UUID /home/pi/share_files ntfs defaults,uid=pi,gid=pi,umask=000 0 0Test the fstab entry without rebooting:
sudo mount -aEnable write support for NTFS
Install the NTFS‑3G driver: sudo apt-get install ntfs-3g -y Load the FUSE kernel module (required by NTFS‑3G): sudo modprobe fuse Reboot the Pi to ensure the driver is active:
sudo rebootAccess the Samba share
Linux (e.g., Ubuntu) : Open the file manager and connect to smb://<em>IP_ADDRESS</em>/share. Authenticate with user pi and the password set earlier.
Windows : Press Win+R, enter \\<em>IP_ADDRESS</em>\share, and provide the same credentials.
Android : Use an SMB client app (e.g., ES File Explorer) and connect to \\<em>IP_ADDRESS</em>\share with the pi credentials.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
