I have a Raspberry Pi zero W, a 32GB SD flash memory card, 4x8GB Cruz USB flash memory sticks. All were salvaged from projects I had built before and for some reason pulled the plug on them.
This project is attempting to prove nothing, it is a "for fun" project. The USB sticks will probably fail if extensive read/write operations were done on them. I will not be going hard on these poor sticks, hence I belive this NAS will last for a while.
I will be creating a logical volume using the 4x8GB USB sticks, then creating a file system and mounting it somewhere (also making it persistent via fstab). Finally I will create a shared folder and make it accessible to the local network via smb.
I will skip the installation of Raspbian on the RPi0W, I have already went throught this process many times already, hence no need to take notes.
Connecting the RPi to a monitor via mini HDMI cable and an external keyboard, I first will need to turn the wifi on. In the terminal, typing the following code will enable it: rfkill unblock wlan
next I need to start and enable the NetworkManager
via this command: for i in start enable restart; do sudo systemctl $i NetworkManager;done
Since this is a RPi0 with wifi capabilities, I will be adding my local routers access points SSID and password to be able to access the internet and the local network, the following command will help me achieving this: sudo nmcli dev wifi con $SSID password $PASSWORD
I need vim, im coding this page using vim, so why not add vim to this server? sudo apt install vim -y
, hmm I think I forgot to update: sudo apt update && sodu upgrade -y && sudo autoremove -y
This is easily done via a google search of "how to harden ssh config", none the less, run: sudo vim /etc/ssh/sshd_config
and modify the following: #port 22
etc.
PermitRootLogin no
Agian, Google has the answer on how to do this, look it up.
Next you will need to restart the SSH service for the changes to take effect, or to turn it on in the first place: for i in start enable restart; do sudo systemctl $i ssh; done
Install lvm2 to create the logincal volume: sudo apt install lvm2 -y
Create a physical volume: sudo pvcreate /dev/[flash drives devices]*
Create a VGroup and call it nas: sudo vgcreate nas /dev/[all the physical volumes
Create the logical volume: sudo lvcreate -L 59G -n nas nas
Now we can create a filesystem from the lv I just created: sudo mkfs.ext4 -m 0 /dev/nas/nas
To mount this filesystem on reboot, add: /dev/nas/nas ext4 defaults 0 2
to: /etc/fstab
Make sure to create the /nas
you just refrenced in the fstab
before remounting: mkdir /nas && mount -a
Finally, you need to change the ownership of the content of /nas
to you/me: sudo shown -R user /nas
Install samba on the RPi0: sudo apt install samba samba-common -y
You need to add the following to /etc/samba/smb.conf
[NAS]
path = /nas/
writeable = yes
create mask = 0775
directory mask = 0775
public = no
Restart the smbd: sudo systemctl restart smbd
Now you can access this share by simply visiting: smb://RPi0_IP