BananaPi/Pro NAS

From BananaPro/Pi
Jump to: navigation, search


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.


Equipments of preparation

  • SBC: BananaPi/Pro
  • SD card image: Raspbian for the B-Pro
  • SATA: 2.5mm pin,+5V 0.85A

(1)Write the OS image file Raspbian for BananaPro to MicroSD card

(2)The 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) 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 drive
1)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


(4)Close the GUI(Graphical User Interface)

sudo nano /etc/X11/default-display-manager

Add false in the file
Pro NAS p1.jpg
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.


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 IP
Edit /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


please note that the IP is my local IP,you should change it according to youself local IP and the gateway 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 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.

comment=my family’s share
valid users=maker
create mask=0777
directory mask=0777

Aria2share is the sharing file’s name that we can see on the computer

(5) Add Samba user
Here 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 User name is maker and password is 321. We can manage our shared file in our phone now. Pro NAS p2.jpg

Step 2:Download machine

(1) Set up aria2
1)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

  1. Basic Options
  • Bt Options
  • RPC Options
  • Advanced Options

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 server
1)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 . Pro NAS p2.1.jpg
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

Pro NAS p3.jpg

After download,extract the compressed file and copy all of the contents under the directory yaaw-master to the directory /aria2download/html. Pro NAS p4.jpg
Now we use Google Chrome or Firefox browse to open the webpage address on our computer then you can see the page as follow. Pro NAS p5.jpg
Yes, we did it. Let’s try it right now.
Pro NAS p6.jpg Pro NAS p7.jpg

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 minidlna
Create 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


Find out #db_dir=/var/lib/minidlna and replace it


Find out #log_dir=/var/log and replace it


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

Pro NAS p8.jpg

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.
Pro NAS p9.jpg
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.
Pro NAS p10.jpg
Pro NAS p11.jpg