Wed. Dec 7th, 2022

We are going to build a NAS (Network Attached Storage) with a RPi 4 or a VM. This will be done with Tools and Apps that are readily available in the linux Distro that you use on a regular basis. We’ll install these and configure them to use as a NAS. Let’s get started:

Install OS (Use RAID0 for multiple drives)
sudo passwd root

note: stop & disable the firewall
sudo systemctl stop ufw
sudo systemctl disable ufw

note: Set server clock to your timezone
sudo timedatectl set-timezone America/New_York

note: Put in your Server Hostname/IP
sudo nano -c /etc/hosts

note: Add the webmin repositories to our build.
sudo nano /etc/apt/sources.list
deb http://download.webmin.com/download/repository sarge contrib

note: Add the webmin gpg key to your repository
sudo wget http://www.webmin.com/jcameron-key.asc
sudo apt-key add jcameron-key.asc
sudo apt update

note: Add the necessary utilities we need to configure the NAS Services
sudo apt -y install tgt samba nfs-kernel-server webmin

note: Here is an excellent article on using open-iscsi
sudo apt -y full-upgrade
sudo reboot

note: Check for drive status
sudo lsblk

note: Create the Raid – I use RAID0/stripe and I only want 1 partition
sudo mdadm –examine /dev/sd[b-c]1
sudo mdadm -C /dev/md0 -l raid0 -n 2 /dev/sd[b-c]1
sudo mdadm –create /dev/md0 –level=stripe –raid-devices=2 /dev/sd[b-c]1
sudo mdadm –examine –brief /dev/sdb1 /dev/sdc1 >> /etc/mdadm/mdadm.conf
cat /proc/mdstat
sudo mdadm –detail /dev/md0


note: Create the filesystem on /dev/md0 (RAID Device)
sudo mkfs -t ext4 -L /dev/md0

note: Create your Mount point I use the /srv others use /mnt
sudo mkdir -p /srv/<folder_name_here>

note: Run fsck to fix any bad blocks on the raid
sudo fsck /dev/md0

note: Mount the array to a mount point
sudo mount /dev/md0 /srv/<folder_name_here>

note: Let’s put this in the /etc/fstab (at the bottom is fine) so we can get this mounted at boot.
/dev/md0 /mnt/raid0 ext4 defaults 0 0
### Let’s apply the changes now ###
sudo mount -a

Log in to Webmin and Configure it to share your files/drives.

goto tools in the left menu:

Click on Tools
Click on File Manager > Then the Directory you created.

Click the check box by the Directory name
Click Tools upper right

In the mode box type 0777 then click the change button at bottom right.
Put in the Share name > Directory to Share > Available/Browseable (Yes) > Click Save
Edit Security and Access Control > Writable (Yes) > Guest Access (Yes) > Click on Save
File mode (777) > Directory mode (777) Allow outside symlinks (Yes) Allow use of Unix extensions (Yes) > Then Click save

Now let’s configure NFS w/Webmin

Click on Networking > NFS Exports > Add New Export
Select the icon at the end of Directory to Export
Read-only (No), Clients must be on secure port (No) > then click create
Click the check box by the Dir you just created > Click Enable Selected > Apply Changes

Last thing is to check access to the share from a linux or a windows box.

I hope you enjoyed the article please come back to our little corner of the world.
Thank you.

By Michael Cooper

30 years in it, Senior Systems Engineer

Leave a Reply

Your email address will not be published. Required fields are marked *