Header Ads

Header Ads

Best cheap NAS for you home

The title actually don't lie, i've managed to make a cheap $35 NAS and no it's not based on RaspberryPI!

What is NAS?
A NAS unit is a computer connected to a network that provides only file-based data storage services to other devices on the network. Although it may technically be possible to run other software on a NAS unit, it is usually not designed to be a general-purpose server. For example, NAS units usually do not have a keyboard or display, and are controlled and configured over the network, often using a browser.

How much NAS costs?
It depends on the various configurations, but consumer products cost a lot. Cheapest Synology NAS you can get for $150, of course it will be empty, without disks.




Lets begin!
It's based on RaspberryPI competitor OrangePI 3 (with power supply) and it supports up to 4 external USB3 disks, uses the AllWinner H6 SoC, and equipped with 1GB/2GB LPDDR3, has 4 USB3 ports and 1gbps ethernet.




You can view full specs here. The speeds from/to it is up to 400MB/s (yes megabytes). We will make it as full compliant iSCSI device, that can easily connected to any Linux or Windows box without any additional configuration. Be warned not to use any of unofficial linux distributions such as armbian, they are not compatible and poorly supported, i've tested it and can confirm that the system is very unstable in orangepi. If we use orangepi's official provided linux distributions such as debian or ubuntu, they work very well, the only downside is that their distributions use the older linux kernel. But everything is stable and well supported. I can recommend installing this distribution to it. Also read release note from their page about login user/password, to access your newly installed system later. The first thing you should do after installing the operating system on device is to connect external HDD to it and setup partition layout. I will use LVM2 (logical disk manager), to make one logical disk of a few physical disks, that configuration is simple and supports great extendability. Also i will not use any redudancy or raid for it, because mainly i've put non important data to NAS, such as media files (Movies, TV shows, music etc...). As from a start i will use only one 8TB HDD, later i will add another.

apt-get install lvm2





































Fist we will create the phisical mark of the LVM on the disk
pvcreate /dev/sda1 
And will check if it's correctly created










Ok, seems that everything is ok, lets continue by creating a LVM group on it
vgcreate mini_iscsi /dev/sda1
Check if it's ok







Now it's time for logical partition creation, we will use 100% of the free space
lvcreate -l 100%FREE -n scsi_storage mini_iscsi
Is it ok?














Last command in our scenario is to finally create the partition on that logical partition
mkfs.ext4 -v /dev/mini_iscsi/scsi_storage















What if we want to add another disk to our NAS?
You must do the same partition layout with fdisk, as we did before, then
pvcreate /dev/sdc1
vgextend mini_iscsi /dev/sdc1
lvextend --verbose --extents +100%FREE --resizefs /dev/mini_iscsi/scsi_storage
Note, that /dev/sdc1 may differ from your configuration, you should see a device name by typing "dmesg" command.

iSCSI Target setup
apt-get install tgt
Create file /etc/tgt/conf.d/storage_iscsi.conf and put these contents to it
<target iqn.2020-02.unix-master.com:lun1>
    backing-store /dev/mapper/mini_iscsi-scsi_storage
    initiator-address 192.168.56.102
    incominguser iscsi-user password
    outgoinguser debian-iscsi-target secretpass
</target>
You should change the initiator-address to your orangepi3 ip address, you can find it by typing "ifconfig eth0" in the terminal.

Now you can start the tgt target service
systemctl restart tgt
We should see details of the initiator issuing this command
tgtadm --mode target --op show
Any future connected sessions can be viewed by this command
tgtadm --mode conn --op show --tid 1
iSCSI Initiator setup 
Don't make mistake, target is the server that has storage in it and initiator is the client for iSCSI, the computer that will access NAS storage via network, i will explain setup using ubuntu 19.10 as the client (initiator).
apt-get install open-iscsi
iscsiadm -m discovery -t st -p 192.168.56.102
We should see the discovered NAS, now we need to edit the configuration
nano /etc/iscsi/nodes/iqn.2020-02.unix-master.com\:lun1/192.168.56.102\,3260\,1/default
And change these values:
node.session.auth.authmethod = CHAP
node.session.auth.username = iscsi-user
node.session.auth.password = password
node.session.auth.username_in = debian-iscsi-target
node.session.auth.password_in = secretpass
node.startup = automatic
Now we need to restart the open-iscsi service
systemctl restart open-iscsi
Seems to be everything is ok, lets check it out with the command
iscsiadm -m session
We should make it out mountable, lets check the device uid by issuing command
blkid
We should see something like

/dev/sdg: UUID="xxx-xxx-xxx-xxx-xxx" TYPE="ext4"
Add it to the /etc/fstab
UUID=xxx-xxx-xxx-xxx-xxx /mnt/media ext4 defaults,_netdev 0 0
Mount it by typing "mount -a" and enjoy your newly created iSCSI NAS. :)


What disks i should buy?
Definitely there is only one competitor at this case, western digital my book.


Stability


It's been a while since i've started it and it seems that everything is working right, the uptime now is 19 days and it runs without any issues or any errors in kernel log itself.
 07:42:55 up 18 days, 14:08,  1 user,  load average: 0.00, 0.00, 0.00

FAQ
Q: Why i've used TGT instead of kernel based ISCSI target
A: Because the orangepi3 kernels does not have iSCSI target nor builtin nor compiled module, you need to pull all official orangepi linux kernel tree, apply lots of patches and rebuild it by yourself, to avoid all that mess, i've considered to use a user-space based target that simply works without any issues. Trust me, there are no speed improvements over there if i've been used a kernel based one...
Q: Does external disks needs some additional power?
A: Of course, all my tested WD My Book drives had external power supplies!
Q: Where can i buy the OrangePI3 case?
A: I personally don't know, maybe you can search trough aliexpress or other China online shops, you can also make it yourself if you have a 3d printer.
Q: I have a question that are not in this FAQ, where should i ask?
A: Write down in the comments section, i've lovely help you in the free time :)

No comments:

Copyright (c) 2012-2013 Unix Master. Powered by Blogger.