Setup NAS on Raspberry Pi
I got my Raspberry Pi 4 8GB model a few months ago. But I only used it for testing Linux system. This powerful toy should be used for something more useful. So I decided to set up a NAS (Network Attached Storage) on it.
Setup static IP address
There are multiple ways of doing this. I am going to use interfaces file to set up static IP address.
Go to /etc/network/interfaces
and add the following lines at the end of the file:
1 |
|
Add NAS IP address to local NAS lookup
Go to /etc/hosts
and add the following line at the end of the file:
1 |
|
Then you can connect to your NAS with ssh user@nas.local
Mount drives
This is optional if you have a large SD card on the Raspberry Pi. I have a 128GB SD card on my Raspberry Pi. But I also have a 1TB external hard drive. So I want to mount the external hard drive to the Raspberry Pi.
Create a mount point
1 |
|
Add the UUID of the drive
1 |
|
Then find the device’s UUID. For me, UUID is 6489-3C57:
1 |
|
Then Add the UUID to fstab:
1 |
|
Explanation of the options:
exfat
: the file system of the driveuser
: allow any user to mount the driverw
: mount the drive as read-writeauto
: mount the drive automatically when the system boots0
: dump. 0 means the drive will not be backed up. 1 means the drive will be backed up (Deprecated).2
: fsck order. 0 means the drive will not be checked. 1 means the drive will be checked first. 2 means the drive will be checked after all the drives with 1 are checked.
Mount driver
1 |
|
Setup Samba
Install Samba
1 |
|
Add the following lines to /etc/samba/smb.conf
:
1 |
|
This creates a share called “mynas” allowing access to all the drives mounted under the /mnt folder.
Read-only is set to no, which permits modifying and writing data to the share.
Browsable allows the share to be seen by a Linux file manager or Windows Explorer.
Add user account
1 |
|
Restart Samba
1 |
|
Finally, you can connect to your NAS with \\nas.local
in Windows Explorer.