Overview
NAS is defined as a special kind of private data storage server, including storage device (such as disk arrays, CD/DVD drives, tape drives, or removable storage medium) and embedded system software, can provide a cross-platform file sharing function.
- BanaNAS-Build your own NAS server through which network you share local resources on the network.
The main function of the NAS home server
(1) File 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.
When you are at home have a disused computer (only computer accessories, hardware drive and power adapter), if you don't try to modified it, ita is discarded waste.Use the rest of the equipment and your bananaPi/Pro can build a NAS server.
Preparation
Equipments of preparation
(1)Write the OS image file Raspbian for BananaPro to MicroSD card
(2)The preparation of hardware1) 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) Plug in an RJ-45 Ethernet.
4) Plugging in the mains adapter power on the Banana Pro.
(3)Format the hard drive to create a new partition and mount the root directory to the hard drive1)Format the hard drive to create a new partition
Run the sudo fdisk /dev/sda command. Use the o command to delete all partition of hard drive and use the n command to add one new partition. Use the w command to save change.
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 MicroSD card, when we need a long time to use the system .Specific methods are as follows.
Create a temporary directory in the root directory
mkdir temp sudo fdisk –l
Mount the /dev/mmcblk0p2 to the temp directory
sudo mount /dev/mmcblk0p2 /temp
Copy the file system to the hard drive partition
sudo mount /dev/sda1 /mnt cp –aP /temp/* /mnt
Edit the /boot/uEnv.txt
sudo nano /boot/uEnv.txt
Change the content root=/dev/mmcblk0p2 as follow
root=/dev/sda1
(4)Close the GUI(Graphical User Interface)
sudo nano /etc/X11/default-display-manager
Add false in the file
Reboot the system then graphical interface is no longer present. Automatically run in the GUI 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.
Implementation
Step 1: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.
(1) Set up static IPEdit /etc/network/interfaces
sudo nano /etc/network/interfaces
Change the iface eth0 inet dhcp as follow
iface eth0 inet static
Add the content as follow
address 192.168.1.15 netmask 255.255.255.0 gateway 192.168.1.1
please note that the IP 192.168.1.15 is my local IP,you should change it according to youself local IP and the gateway 192.168.1.1 is my local gateway,you should change it according to youself local gateway.
And then delete iface default inet dhcp 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) Installation of samba services
sudo apt-get update sudo apt-get install samba sudo apt-get install samba-common-bin
(3) Add user and create the download directory
sudo useradd maker
To set a password for the new user, this is set to 123
sudo passwd maker sudo mkdir /aria2download/download sudo chown –R maker /aria2download/download
(4) Edit the samba configuration file
sudo nano /etc/samba/smb.conf
To find out the security = user and delete the symbol # in front of the sentence,ctrl+w is the key of the search function in nano editor. Add the content at the end of the file.
[aria2share] comment=my family’s share path=/aria2download/download valid users=maker public=no writable=yes browseable=yes create mask=0777 directory mask=0777
Aria2share is the sharing file’s name that we can see on the computer
(5) Add Samba userHere we set Samba password is 321
sudo smbpasswd -a maker sudo service samba restart
So far we have established the file server based on samba. Type the Winkey+R and 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.
Step 2:Download machine
(1) Set up aria21)Install aria2
sudo apt-get install aria2
Create a new directory and file.
sudo mkdir /etc/aria2 sudo touch /etc/aria2/aria2.session
2)To configure the aria2
sudo nano /etc/aria2/aria2.conf
Edit /etc/aria2/aria2.conf. The meaning of the content you can refer the aria2 manual from http://aria2.sourceforge.net/manual/en/html/aria2c.html.
- Basic Options
dir=/aria2download/download input-file=/etc/aria2/aria2.session max-concurrent-downloads=20 continue=true lowest-speed-limit=0 max-connection-per-server=5 min-split-size=10M split=5
- Bt Options
bt-enable-lpd=true bt-max-open-files=100 bt-max-peers=55 bt-min-crypto-level=plain bt-require-crypto=true follow-torrent=true listen-port=6881-6999 max-overall-upload-limit=0 max-upload-limit=0 seed-ratio=1 seed-time=120
- RPC Options
enable-rpc=true rpc-allow-origin-all=true rpc-listen-all=true
- Advanced Options
disable-ipv6=true file-allocation=falloc max-overall-download-limit=0 max-download-limit=0 save-session=/etc/aria2/aria2.session 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 aria2 boot 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.
(2)To build web server1)Install nginx
sudo apt-get install nginx
Create a new directory
sudo mkdir /aria2download/html sudo chmod 777 /aria2download/html
2)To configure the nginx
sudo nano /etc/nginx/sites-available/default
Find out sentence #listen 80 ; and delete the symbol #. Underneath change the sentence root/usr/share/nginx/html to root/aria2download/html . 3)Reload and restart the nginx
sudo /etc/init.d/nginx reload 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.
Step 3:Install the DLNA steaming media server
DLNA is mainly oriented to media resources (such as video, music) to realize the network sharing. The setting steps as follows:
(1) Install minidlna
sudo apt-get install minidlna
(2) Configure the minidlnaCreate the directory
sudo mkdir /aria2download/minidlna sudo mkdir /aria2download/minidlna/dd sudo mkdir /aria2download/minidlna/log sudo chmod 777 -r /aria2download/minidlna
Edit /etc/minidlna.conf
sudo nano /etc/minidlna.conf
Find out media_dir=/var/lib/minidlna and replace it
media_dir=/aria2download/download
Find out #db_dir=/var/lib/minidlna and replace it
db_dir=/aria2download/minidlna/db
Find out #log_dir=/var/log and 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/lib/minidlna rm –r /var/log
(3)Restart minidlna
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 Player in the LAN.
We also can see it on our mobile phone via the streaming media player software. Here I use moliplayer. NAS home server finally completed! We can put the server on a corner of home working for us, now.
Comments