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.
Image courtesy of Lemaker
The 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.
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.
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.
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:
...and this command writes the Lubuntu image:
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.
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.
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.
Use these commands to download the latest patches and updates:
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:
or this command to reboot it:
See also: Banana Pi quick start
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:
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.
Use this command to start the fdisk partitioning tool:
Type 'p' to list all the partitions on the disk:
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:
None of the changes made so far have been written to the disk. We can do this by typing 'w' at the prompt:
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.
Type 'w' to write the changes to the disk again.
Next, format the new partition with the ext4 filesystem:
Mount the partition, and use rsync to copy the contents of the SD card's root directory to the SATA 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:
The file should look like this once you've made the changes:
Finally, restart your server. When it starts up again, it should use the hard disk as the root file system.
There are a number of settings which people often change when they have just installed Linux.
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:
If you wish to start a desktop session from the command line, use this command:
If you want Lightdm to start on boot up again, use this command:
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.
Now all commands are executed as the root user. Change to a different directory than /home/pi:
Use the usermod command to change username of the default account
When you reboot, you'll need to log in using the new user name.
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:
You will be prompted to enter your current password, followed by your new password twice.
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:
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:
Look for an entry with IP address 127.0.1.1, and change the host name as required.
Reboot your Banana Pi, and you should see that its host name has changed.
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:
Now create new keys:
A new set of ssh keys will be generated in /etc/ssh.
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:
Generate the keys:
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:
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.
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:
If you're not using a desktop environment, you can resize the partition from the command line using the fdisk command:
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.
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:
The partition and its file system should now occupy the whole SD card.
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.
Click the Apply button on the Gparted tool bar to write the changes to the card. The partition will be enlarged, and the file system is automatically expanded to fill the partition.
Share this page: