In my last post I talked about the Odroid-XU4 as my favourite single board computer (SBC). In this post I will will walk you through the steps I performed to create a Home NAS.
Before I set up the NAS, I had to think about how I really wanted to use it. Primarily, it was going to be a location to share files with everyone in the home. In my case it was photos and music. But, I also wanted to have some sort of back up for all the computers in the home. This lead me to have a single sign-on for the NAS. I created a user called ‘odroidnas’ and gave it a secure password. I did not add this user to list of sudo users because I did not want my teenage son to mess around with the Odroid.
sudo adduser odroidnas
I then made sure my version of Samba (our file sharing software) was up to date.
sudo apt-get update sudo apt-get upgrade sudo apt-get install samba samba-common-bin
Then it was time to add the 4TB external drive that would become our NAS. I picked up a 4TB portable Seagate drive at BestBuy when it was on sale for about C$100. I prefer the portable drives since they do not need to be plugged into a power outlet. They get the power from the USB connection.
I was not sure if the Odroid was going to be able to power multiple drives, that is why I added a 4 port powered USB 3.0 hub to the Odroid. Here is the one I am using from Amazon. In the end, I ended up adding three 4TB drives to my Odroid.
After plugging in the drive, it was time to make sure it mounted and started sharing when the Odroid was started/restarted.
First I wanted to make sure the drive could be read by Windows PC’s attaching to it. I added the ability to read and write Windows formatted (NTFS) drives to the Odroid.
sudo apt-get install ntfs-3g
I then made sure the drive was mounted.
sudo mount -a
Then I create a mount point for the external drive and give it the correct permissions so that the user ‘odroidnas’ can read and write to the disk. Some readers might not like giving a directory full read/write privileges, but this is a NAS inside my home for the whole family to use, so I was comfortable using ‘775’ when setting up the privileges.
sudo mkdir /mnt/nas sudo chown -R odroidnas:odroidnas /mnt/nas sudo chmod -R 775 /mnt/nas
Then it was time to find the unique identifier for the portable drive.
ls -l /dev/disk/by-uuid
Then I need to make sure the drive mounts in the same location every time the device reboots. Fstab is used to mount drives in Linux.
sudo nano /etc/fstab
Then add the following line to fstab:
PARTUUID=unique identifier from above /mnt/nas ntfs-3g defaults,nofail 0 0
To test if this works I rebooted the Odroid.
sudo reboot now
After rebooting, I checked to see if the drive mounted.
In my case, after it rebooted the drive was found at
/mnt/nas. However, some drives are slow to mount and may not appear in the list. There is a workaround:
sudo nano /etc/rc.local
Then you can add the following lines before end ‘end 0’:
sleep 20 mount -a
If you are like me and find the flashing blue light of the Odroid annoying, you can also add this line after ‘
mount -a‘ to keep it from flashing.
echo none > /sys/class/leds/blue\:heartbeat/trigger
Now it is time to set up the Samba. Open the Samba configuration file:
sudo nano /etc/samba/smb.conf
Then add the following (you can customise the name):
[OdroidNAS] comment=Home NAS on Odroid path=/mnt/nas create mask=0777 directory mask=0777 writeable=yes public=no guest ok=no browseable = yes force user = odroidnas
Give the user ‘odroidnas’ access to the Samba server by first giving it a password. In my case, I used the same password as when I set up the ‘odroidnas’ user above.
sudo smbpasswd -a odroidnas
Then restart the Samba server.
sudo service smbd restart
We now have a server, but we need to tell our laptop and desktop PC’s how to talk to it. First we need to know the IP address of the server. If you are like me, you want it to be static. I went into my home router and reserved the IP address of the Odroid so that it would have the same IP every time. You can check the IP address by using the command:
ip addr show
Connecting a Mac:
- Command + k to bring up the ‘Connect to Server’ dialogue box.
- Enter the pathway: smb://192.168.x.x/OdroidNAS
- Enter the username (odroidnas) and password
- Bonus: you can also click the ‘+’ button to remember the server.
On a PC, here are the steps:
- Open File Explorer from the taskbar or the Start menu
- Select This PC from the left pane. Then, on the Computer tab, select Map network drive. Map a network drive in File Explorer
- In the Drive list, select a drive letter. (Any available letter will do.)
- In the Folder box, type the path of the folder or computer, \\192.168.x.x\OdroidNAS
- To connect every time you log on to your PC, select the Reconnect at sign-in check box.
- Also check Connect Using Different Credentials, enter the user ‘odroidnas’ and the password.
- Select Finish.
You now have a NAS that anyone in the home can use to store and share files. This is really important to me since my laptop has a small solid state drive but I can now access my photo collection easily on my NAS.
Next time I will share my backup strategy for my laptops, desktops, and NAS.
[There a many guides on the Internet. This is my implementation created from information on a variety of sites. A great site to check out is PiMyLifeUp. I would also like to thank Andrew Dobbie for his interest in my experimentation with my Odroid.]