NAS or Network Attached Storage is basically an FTP (File Transfer Protocol) server with some storage device attached to it, that is it can be accessible from another computer.
I know all that stuff, take me to the software setup
NAS servers can be used for a some reasons like:
Either one of the methods requires a high speed network switch or router, for example, an HDD setup requires at least a 1Gbps network, since HDDs can have a speed up to 100MBps, SSDs need at least 10Gbps, and so on...
A proper RAID setup is a plus, that is to improve performance (dedicates drives accesses) and for data redundancy (some RAIDs have copies of the drives) but more on RAID later, as of the time that I'm writing this I only have a 1TB and 500GB HDDs.
Side note: I'm not advertising any of the products, I just use them because they're good, and actually lasted with no faults for the past 4 years (expect for the USB hub that one is new, part of a renewal, stay tuned).
Now for the power, the USB hub is a giga chad on its own, since it takes in 40W of power which is enough to power everything from it, and that's exactly what I did, since it has a 2.4A USB port, which is what the Raspberry Pi needs, since the HDDs are gonna be powered using the hub.
However the Raspberry Pi needs a bit of power on startup beyond 2.4A since booting up is a hard task and the little guy has too much to do...
And a moment of appreciation for the hub's power switch, which is super handy (given that the Raspberry Pi doesn't have one by default)
Anyways, I hooked the HDDs to the hub, the Raspberry Pi to the power port on the hub, the hub's data cable to one of the Raspberry Pi's USBs and the Raspberry Pi to the router using an RJ-45 (Ethernet) cable.
Just a declaimer, I'm using Linux on both the client and server, but it's simple FTP, you can check the configuration for your OS on your own.
This one is easy, since it's just installing the FTP server software and doing a bit of fstab configuration.
vsftpd
, using your distro's package manager, it's included on all Linux distro's that I've tested on. but since I'm using a Raspberry Pi with Raspberry Pi OS, I'll just use apt
sudo apt install vsftpd
vsftpd
, by editing the file /etc/vsftpd.conf
and un-commenting the linesanonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
chroot_local_user=YES
user_sub_token=username
local_root=/path/to/your/mounted/disks
In my case these will be:
user_sub_token=baraa
local_root=/home/baraa/disks
vsftpd
's servicesudo systemctl enable --now vsftpd
sudo blkid
, you should expect output like this
PARTUUID
value which will use to mount the drives (using UUID is essential so that we don't mix the drives)mkdir -p ~/disks/disk{1,2}
fstab
, edit the file /etc/fstab
and add the following:# drive mount-point file-system flags priority
PARTUUID=bf6011f2-01 /home/baraa/disks/disk1 ntfs nosuid,nodev,nofail 0 0
PARTUUID=d9e4b195-6654-46fd-aad8-dc1d4f5d7302 /home/baraa/disks/disk2 ext4 nosuid,nodev,nofail 0 0
fstab
configuration:sudo mount -a
The client's configuration has lesser hassle, I swear!
Assuming, and since I'm assuming that means, you must've setup the server using SSH, if not configure SSH on it :)
Now mount the FTP drives to your computer using sshfs
by running
sshfs user@host:dir /local/path
This will prompt for your user's password on the server, enter it and you shall have your mounted drive.
In my case I've created this handy script that does the thing for the two drives, where it mounts them to the directory lilnas
on my home directory.
#!/bin/bash
# edit the script to fit your needs, I made the script, so that I run it whenever I'm home.
echo "mounting disk1..."
sshfs baraa@16.0.0.2:/home/baraa/disks/disk1 ~/lilnas/disk1/ && echo "done!"
echo "mounting disk2..."
sshfs baraa@16.0.0.2:/home/baraa/disks/disk2 ~/lilnas/disk2/ && echo "done!"
Bonus: fun fact, using ssh
or sshfs
without the username, will omit the user from the current username, that is since I'm using my computer with the user baraa
and I want to SSH to the server with the user baraa
on the server, I can just do this:
ssh 16.0.0.2
# or
sshfs 16.0.0.2:/home/baraa/disks/disk2 ~/lilnas/disk2/
And it will login using the username baraa
on the server, since it's the current active user on my computer.