I have an old computer out of use that just have the computer case, hard drive and a power supply. If you don’t use those devices, they will be wasted. So I use the surplus equipment and Banana Pro (Using Banana Pi can achieve the same effect)set up my NAS home server.
The main functions of the NAS home server
1File server: Use samba to realize the file sharing.
2 Download machine:Use aria2c to realize the automatic download.
3 Streaming media server: DLNA realize the use of computer or mobile phone playing the media files that were placed in the sharing directory.
The steps are as follows.
1 Preparation work
1.1 Write the OS image file Raspbian for Banana Pro to Micro SD card
1.2The preparation of hardware
(1)Use the power supply to supply power for the hard drive
(2)Connect the hard drive to the SATA port on the B-Pro
(3)Plugin an RJ-45 Ethernet
(4)Plugging in the mains adapter power on the Banana Pro.
1.3 Format the hard drive to create a new partition and mount the root directory to the hard drive
(1)Format the hard drive to create a new partition
Run the sudo mkfs.ext4 /dev/sda1 command to format the new created partition of hard drive as ext4.
(2) Mount the root directory to your hard drive
When we mount the root directory to the hard drive, the file system will start in the hard drive. This setting is a good way to protect our Micro SD card, when we need a long time to use the system .Specific methods are as follows:
Create a temporary directory in the root directory
cp –aP/temp /mnt
Edit the /boot/uEnv.txt,
Change the contentroot=/dev/mmcblk0p2as follow>root=/dev/sda1
1.3 Close the GUI
Reboot the system then graphical interface is no longer present. Automatically run in the CUI mode when the system reboot. The machine does not need to use the GUI. The graphical interface for the B-Pro was closed to save computational resources.
2 Create a file server
Use the file server can achieve LAN file sharing. Through this function we can upload files to the shared directory or download files from the shared directory. Here we use the samba software to realize our LAN sharing.
2.1Set up static IP
iface eth0 inet static
Add the content as follow
gateway 192.168.1.1
And then delete iface default inetdhcp
Here the static IP is set to 192.168.1.15. Restart the network or reboot the system to finish it.
sudo /etc/init.d/networking restart
2.2 Installation of samba services
sudo apt-get install samba-common-bin
2.3 Add user and create the download directory
sudouseradd maker
To set a password for the new user, this is set to 123
sudochown –R maker /aria2download/download
2.4Edit the samba configuration file
sudonano /etc/samba/smb.conf
To find out the security = user and delete the symbol# in front of the sentence.
Add the content at the end of the file.
directory mask=0777
Aria2share is the sharing file’s name thatwe can seeon the computer
2.5Add Samba user
Here we set Samba password is 321
sudo service samba restart
So far we have established the file server based on samba. Type the Winkey+Rand input our IP address of the server. Then we will see our sharing file on the computer. On the mobile phone use software ES file explorer to view the sharing file. In my network page of the ES file explorer click the new option and input the path of our sharing file like IP/sharing filename then input user name with password. Here I input 192.168.1.15/aria2share. User name is maker and password is 321.We can manage our shared file in our phone now.
3 Download machine
3.1Set up aria2
(1)Install aria2
sudo apt-get install aria2
Create a new directory and file
sudomkdir /etc/aria2
sudo touch /etc/aria2/aria2.session
(2) To configure the aria2
sudonano /etc/aria2/aria2.conf
Edit /etc/aria2/aria2.conf. The meaning of the content you can refer thearia2 manual from http://aria2.sourceforge.net/manual/en/html/aria2c.html
#Basic Options
split=5
#BtOptions
seed-time=120
#RPC Options
rpc-listen-all=true
# Advanced Options
save-session-interval=300
Save configuration and test the function
aria2c --conf-path=/etc/aria2/aria2.conf -D
To see whether aria2 is running
ps –ef|grep aria2
(3)Enable aria2boot as the system start
Edit /etc/rc.lcal,and insert the following contents before exit0.
sudo aria2c --conf-path=/etc/aria2/aria2.conf –D
The next time you start Pro, aria2 will automatically run
3.2 To build web server
(1)Install nginx
sudo apt-get install nginx
Create a new directory
sudochmod 777 /aria2download/html
(2) To configure the nginx
sudonano /etc/nginx/sites-available/default
Find out sentence #listen 80; and delete the symbol#. Underneath change the sentence root /usr/share/nginx/htmltoroot /aria2download/html
(3)Reload and restart the nginx
sudo /etc/init.d/nginx restart
(4)Install yaaw
Download the yaaw from https://github.com/binux/yaaw
After download,extract the compressed file and copy all of the contents under the directory yaaw-master to the directory /aria2download/html.
Now we use Google Chrome or Firefox browse to open the webpage address 192.168.1.15 on our computer then you can see the page as follow.
Yes, we did it. Let’s try it right now.
4 Install the DLNA steaming media server
DLNA is main lyoriented to media resources(such as video,music)to realize the net work sharing.The setting steps as follows:
4.1 Install minidlna
sudo apt-get install minidlna
4.2 Configure the minidlna
Create the dircreatory
sudochmod –r 777 /aria2download/minidlna
Edit /etc/minidlna.conf
sudonano /etc/minidlna.conf
Find out media_dir=/var/lib/minidlnaand replace it
media_dir=/aria2download/download
Find out #db_dir=/var/lib/minidlnaand replace it
db_dir=/aria2download/minidlna/db
Find out #log_dir=/var/logand replace it
log_dir=/aria2download/minidlna/log
Last find out the default minidlna database and log files then delete it to avoid confusion
rm–r /var/log
4.3 Restart minidna
sudo /etc/init.d/minidlna restart
To see whether aria2 is running
/etc/init.d/minidlna status
We have successfully established a streaming media server. But we need to turn off the firewall or allow the Windows Media Player through the firewall before we use it. Now we can see the sharing streaming media files by the Windows Media Playerin the LAN.
We also can see it on our mobile phone via the streaming media player software. Here I use moli player.
NAS home server finally completed! We can put the server on a corner of home working for us, now.
Comments