Share this page:

Banana Pi

The Banana Pi is an ARM powered mini-computer inspired by the Raspberry Pi.  The Banana Pi has a 1GHz dual core processor with 1GB of DDR3 RAM.  It has a gigabit ethernet socket, and an on board SATA connector. Several Linux distributions are available including Raspbian and Ubuntu.  

This site is hosted on a Banana Pi cluster running Raspbian, and it was built using Pyplate CMS.

Banana Pi

Image courtesy of Lemaker

Specifications

  • SoC: AllWinner A20, ARM Cortex A7 dual core, 1GHz
  • Mali400MP2 GPU
  • 1GB DDR3 RAM
  • SD card slot
  • SATA socket
  • Video output: HDMI, CVBS, Composite
  • Sound: HDMI, CVBS, 3.5mm stereo output, microphone input
  • Gigabit ethernet
  • 2 USB Host ports
  • 1 OTG Micro USB port
  • 1 micro USB socket for power
  • IR Receiver
  • 3 push buttons (Power, Reboot, Uboot key)
  • 26 pin GPIO header
  • Camera connector
  • LVDS/touch screen connector

Lemaker logoThe Banana Pi was developed by LeMaker in Shenzhen in China.  It is an open source platform intended mainly for educational uses.  

LeMaker are committed to the open source philosophy and sharing with the Linux community.

 


Comments

Set up Linux

Download a Linux image

Several versions of Linux have been ported to the Banana Pi.  Two of the most commonly used are Raspbian and Lubuntu.  Raspbian is a simple version of Linux originally developed for the Banana Pi.  

Lubuntu is a compact version of Ubuntu designed for running on lower spec hardware than a typical PC.  The procedure for setting up either version of Linux is the same.  

Linux disk images can be downloaded from Lemaker's web site.  The files are in the .tgz (tar and gzip) file format, so if you're using a Windows computer to prepare the card, you'll need to install 7 Zip in order to unpack the archive.  If you're using a Linux PC, you can just use the archive manager supplied with your distribution.

Once you have extracted the .img file from the .tgz archive, you need to burn it to your SD card.

Prepare an SD card

The minimum size needed for the Raspbian and Lubuntu images is 4GB.  It's recommended that you use class 10 SD cards for better performance.  I'm using an 8GB SanDisk Ultra SDHC card. 

If you already have an existing Linux distribution installed on your SD card (for example, if you've been using your SD card with a Raspberry Pi), it is recommended that you wipe existing paritions using GParted.  You don't need to create a new partition, just delete the old ones.  The necessary partitions will be created when the image is burnt to the card.

Burn the image using a Linux PC

Insert your SD card into your PC's SD slot (or use an adapter).  On my PC, the  SD card shows up as /dev/sde.  It's important to correctly determine which device in /dev represents your SD card.  If you write the image to the wrong one, you may corrupt your PC's hard disk.  If your PC automatically mounts the card you should unmount it.

The dd command is used to write an image to the SD card.  This command writes the Raspbian image to the card:

su -c ‘dd bs=4M if=./Raspbian_For_BananaPi_v2_0.img of=/dev/sde’

...and this command writes the Lubuntu image:

su -c ‘dd bs=4M if=./Lubuntu_1404_For_BananaPi_v3_0.img of=/dev/sde’

Set up the Banana Pi

I'm using a USB Wifi dongle to connect my Banana Pi to my home network, and I also plan to use a mouse and keyboard with my Pi.  Since it only has two USB sockets, I've connected a USB hub to my Pi and plugged in the mouse, keyboard and wifi dongle to the hub.  I'm using a powered hub so that the USB devices don't draw power from the Banana Pi.  I connected the Banana Pi to a monitor using an HDMI cable with a DVI adapter.

Set up a Banana Pi

Image courtesy of Lemaker.

Connect the power cable last.  After a few seconds you should see boot messages scrolling up the screen.  If you have installed the Lubuntu image, you'll be prompted for a password. Enter bananapi.  

Set up networking

If there is an ethernet cable attached to your Pi when it boots up, an IP address will be allocated by DHCP.

If you're not using ethernet and you have a USB wifi dongle attached to your Pi via a USB hub, you will need to enter a security key.  You can get the security key by looking at the settings in your home router.  

In Raspbian you need to double click on the wifi icon on the desktop.  A window will appear with a Scan button.  Click on the scan button, and wait for your wifi access point to be listed. Double click on your access point and enter the security key in the window that pops up.

In Lubuntu, there's a networking icon in the bottom right hand corner of the screen.  Clicking on this will display a menu with various networking options.  Available access points should be listed in this menu (if not, look for a search option).  Click on the access point, and enter the security key when prompted.

Install updates

Use these commands to download the latest patches and updates:

sudo apt-get update
sudo apt-get upgrade

The first time you do this, it will take a long time to install all the available updates.  You should update your Banana Pi regularly to make sure you get security patches.  You should also update your Banana Pi before you install new software.

Use this command to shutdown your Pi:

sudo halt

or this command to reboot it:

sudo reboot

See also: Banana Pi quick start


Comments

Set up Raspbian on a SATA hard disk

Installing Linux on a SATA hard disk will allow Linux to run faster, and increase the amount of storage on your system.  I powered my SATA disk using a separate power supply (I don't have a cable that matches the Banana Pi's SATA power socket). 

Set up Raspbian on an SD card as described in this post on /set-up-linux.html setting up Linux on a Banana Pi, but don't install updates.  Connect your disk to the Banana Pi's SATA socket, but don't power up the disk.  

Open a terminal and run this command to display new messages in one of Linux's log files:

tail -f /var/log/messages

Power up the SATA disk, and look for the new drive in the messages in the terminal.  If the drive is auto-mounted when you connect it, unmount it.

Partition the disk

Use this command to start the fdisk partitioning tool:

sudo fdisk /dev/sda

Type 'p' to list all the partitions on the disk:

Command (m for help): p

Disk /dev/sda: 100.0 GB, 100030242816 bytes
255 heads, 63 sectors/track, 12161 cylinders, total 195371568 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x99b699b6

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1              63       96389       48163+  de  Dell Utility
/dev/sda2   *       96390   102494699    51199155    7  HPFS/NTFS/exFAT
/dev/sda3       102494700   195366464    46435882+   5  Extended
/dev/sda5       102494763   183639014    40572126   83  Linux
/dev/sda6       183639078   195366464     5863693+  82  Linux swap / Solaris

Remove existing partitions

I'm going to delete all of these partitions, and replace them with one partition that fills the entire disk.  Press 'd' to delete a partition, and then enter the number of the partition to be deleted:

Command (m for help): d
Partition number (1-6): 1

Command (m for help): d
Partition number (1-6): 2

Command (m for help): d
Partition number (1-6): 3

Write the changes to the disk

None of the changes made so far have been written to the disk.  We can do this by typing 'w' at the prompt:

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Fdisk will automatically quit.  Restart fdisk so that you can create a partition, and type 'n' to create a new partition.  When prompted for the type, press 'p' for primary, and enter '1' for the partition number.  Just press return to use the default values when prompted to enter the first and last sectors.

sudo fdisk /dev/sda

Command (m for help): n   
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-195371567, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-195371567, default 195371567): 
Using default value 195371567

Type 'w' to write the changes to the disk again.  

Format the partition

Next, format the new partition with the ext4 filesystem:

sudo mke2fs -t ext4 -L rootfs /dev/sda1
mke2fs 1.42.5 (29-Jul-2012)
Filesystem label=rootfs
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6111232 inodes, 24421190 blocks
1221059 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
746 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   

Copy the data

Mount the partition, and use rsync to copy the contents of the SD card's root directory to the SATA disk.

sudo mount /dev/sda1 /media
sudo rsync -ax / /media

Adjust boot parameters to use the new disk

The last step is to edit a file on the SD card's boot partition which contains boot parameters.  The file is /boot/uEnv.txt (on the Raspberry Pi the equivalent file is /boot/cmdline.txt).  It contains a variable called 'root', and it needs to be adjusted to point to the new partition, /dev/sda1:

sudo nano /boot/uEnv.txt

The file should look like this once you've made the changes:

bootargs=console=ttyS0,115200 console=tty0 disp.screen0_output_mode=EDID:1280x720p50 hdmi.audio=EDID:0 console=tty1 root=/dev/sda1 rootfstype=ext4 elevator=deadline rootwait
aload_script=fatload mmc 0 0x43000000 bananapi/script.bin;
aload_kernel=fatload mmc 0 0x48000000 bananapi/uImage; bootm 0x48000000;
uenvcmd=run aload_script aload_kernel

Finally, restart your server.  When it starts up again, it should use the hard disk as the root file system.  


Comments

Change default settings

There are a number of settings which people often change when they have just installed Linux.

Stop Raspbian from booting to the desktop

If  you are using your Banana Pi as a server, you may not need to use the Lightdm desktop environment, and just let your Banana Pi boot to a command line interface.  

When Raspbian boots, it executes scripts in /etc/init.d to start various services, including Lightdm.  You can use the update-rc.d command to prevent any of these scripts from running. This command stops Lightdm from running when you boot your Pi:

sudo update-rc.d -f lightdm remove

If you wish to start a desktop session from the command line, use this command:

sudo service lightdm start

If you want Lightdm to start on boot up again, use this command:

sudo update-rc.d -f lightdm defaults

Change the default username

Many Linux images have a default username and password.  The default username and password for the Raspbian image are 'pi' and 'bananapi' (in many of the Banana Pi Linux distributions, the default username is bananapi).  It's best to change these login details so that no one else can log into your Pi. 

You need to configure your Pi to boot to a command line - the following procedure won't work if you're logged into a desktop session.  Once you've booted to a command line, you need to change the shell session to the root user.  This is necessary because you can't modify a user account while you're logged in as that user.

exec sudo -s

Now all commands are executed as the root user. Change to a different directory than /home/pi:

cd /

Use the usermod command to change username of the default account

usermod -l steve -d /home/steve -m pi

When you reboot, you'll need to log in using the new user name.

Change the default password

One of the most important things to change is the password.  Using the default password is a monumental security risk.  The default password for most Banana Pi Linux distributions is simply bananapi. Change it using the passwd command:

passwd
Changing password for steve.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:

You will be prompted to enter your current password, followed by your new password twice.

Change the hostname

The hostname is the name of your server as it appears on your local network.  You may need to change the hostname if you have more than one Banana Pi on your network. You'll need to change it in two places:

  1. /etc/hostname
  2. /etc/hosts

The hostname is set in /etc/hostname.  This file only contains the hostname.  Open it as root, and change the name.  I've change it from 'lemaker' to 'bpi'. 

In /etc/hosts, there's a list of IP addresses and their host names.  This file contains a table mapping IP addresses to host names.  Open it with this command:

sudo nano /etc/hosts

Look for an entry with IP address 127.0.1.1, and change the host name as required.

127.0.0.1    localhost
::1        localhost ip6-localhost ip6-loopback
fe00::0        ip6-localnet
ff00::0        ip6-mcastprefix
ff02::1        ip6-allnodes
ff02::2        ip6-allrouters

127.0.1.1    bpi

Reboot your Banana Pi, and you should see that its host name has changed.

Update SSH keys

If you're using a version of Linux installed from an image, the image may already contain keys. These keys are the same for anyone who's installed the same image, so it's important to change them.

There are keys that the ssh server daemon uses to authenticate incoming connections, which need to be removed:

sudo rm /etc/ssh/ssh_host_*

Now create new keys:

sudo dpkg-reconfigure openssh-server

A new set of ssh keys will be generated in /etc/ssh.

Generate user ssh keys

Users can generate ssh keys for themselves so that they can easily authenticate with ssh servers on other hosts.  Using keys means users can be identified by their keys without needing to type a password.

Create a folder in my hom folder to store inthe keys:

mkdir ~/.ssh
chmod 700 ~/ssh

Generate the keys:

ssh-keygen -t rsa -C steve@bpi

You'll be prompted for a place to save the keys.  Just press return to use the default location. This will create a pair of RSA key files in ~/.ssh/.

The public key must be transferred to any device I wish to log into with ssh.  For example, if I wanto to log into another Linux host at IP address 192.168.0.3 as user dave, I would use this sequence of commands to transfer the public key:

cat ~/.ssh/id_rsa.pub | ssh dave@192.168.0.3 'cat >> ./.ssh/authorized_keys'

It's necessary to type a password the first time the connection is made, but after that it's possible to connect to this device without typing a password.


Comments

Resize the root partition

Most of the Linux distributions available for the Banana Pi can be downloaded as a disk image from Lemaker's web site.  Most of these images take up 4GB when unpacked and copied to an SD card.  There's a small Fat16 partition used for storing boot files, and a 3.7GB ext4 partition for storing the root file system.  

When you install updates on a new disk image, you may find that the Linux partition fills up before all the updates have installed.  It's a good idea to use an 8GB card (or larger), and resize the partition so that it fills the entire card.

If there's any important data on your SD card, you should back it up before you make any changes.

The card shouldn't be mounted while you resize it, so you need to put it in an SD card reader and plug it in to a Linux PC.  If you have a spare SD card, you can boot a Banana Pi with one SD card, and use it to resize the Linux partition on a second SD card.

Use this command to view the disks and their partions:

$ sudo fdisk -l
Disk /dev/mmcblk0: 7.4 GiB, 7948206080 bytes, 15523840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x59d0bd13

Device         Boot     Start       End  Blocks  Id System
/dev/mmcblk0p1           2048    104447   51200  83 Linux
/dev/mmcblk0p2         104448  15523839 7709696  83 Linux

Disk /dev/sda: 7.5 GiB, 7998537728 bytes, 15622144 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x59d0bd13

Device    Boot     Start       End  Blocks  Id System
/dev/sda1           2048    104447   51200  83 Linux
/dev/sda2         104448   7167999 3531776  83 Linux

Expand the partition with fdisk

If you're not using a desktop environment, you can resize the partition from the command line using the fdisk command:

sudo fdisk /dev/sda

Fdisk will display a prompt where you can enter simple commands.  You're going to need to delete the second partition, create a new larger one, and write the changes to disk.  The partition table will be updated, but the data in the partition will be untouched.  

When you create the new partition you'll be prompted for a type, primary or extended.  Type 'p' for primary, and enter '2' when prompted for the partition number.  When prompted for the first and last sector numbers, just press enter to use the default values selected by fdisk.

The next step is to type 'w' to write the changes to the card.  Fdisk will automatically quit after this.

[bananapi@lemaker ~]$ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.24.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

Command (m for help): n

Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (104448-15622143, default 104448): 
Last sector, +sectors or +size{K,M,G,T,P} (104448-15622143, default 15622143): 

Created a new partition 2 of type 'Linux' and of size 7.4 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Reboot your Banana Pi so that the partition table gets reloaded.  At this point, the partition is much larger, but the file system only occupies half of it.  The final step is to enlarge the file system so that it fills the partition.  The next two commands check the integrity of the file system and then resize it:

[bananapi@lemaker ~]$ sudo e2fsck -f /dev/sda2
e2fsck 1.42.8 (20-Jun-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda2: 82882/220752 files (0.1% non-contiguous), 724877/882944 blocks

[bananapi@lemaker ~]$ sudo resize2fs /dev/sda2
resize2fs 1.42.8 (20-Jun-2013)
Resizing the filesystem on /dev/sda2 to 1939712 (4k) blocks.
The filesystem on /dev/sda2 is now 1939712 blocks long.

The partition and its file system should now occupy the whole SD card. 

Expand the partition with Gparted

Some Linux distributions are supplied with a graphical tool called Gparted, which is available in the Fedora image for the Banana Pi.  It's available on many PC Linux distributions by default.  If you're using Fedora on your Banana Pi, you can use Gparted instead of fdisk.

Before you start, make sure the card is plugged into an SD card reader, and make sure the card isn't automatically mounted.  Launch Gparted by going to the Application Menu -> System -> Gparted.  

Select the card that you want to edit from the drop down menu on the right hand side of the tool bar.  In this case it's /dev/sda.  Click on the partition /dev/sda2, go to the Partition menu, and select Resize/Move.

Resize the partition
In the resize window, drag the right hand edge of the partition as far to the right as it will go, and click on the Resize button. 

Click the Apply button on the Gparted tool bar to write the changes to the card.  The partition will be en;arged, and the file system is automatically expanded to fill the partition.


Comments