Move Linux Banana Pi SATA Setup

banana-pi-square logoThe Banana Pi is a superior mini computer to the Raspberry Pi in terms of raw power. When I read about the Banana Pi I knew it would be a formidable opponent as a home media server, for HTPC serving purposes, the Banana Pi does everything the Raspberry does, just faster. For those with less patience (sometimes myself) but want to keep their electricity bill down, the BPi is a wise choice. One of my reasons for choosing the Banana Pi was its SATA port and the ability to connect an SSD to run Linux (Debian, Ubuntu, Raspbian) so everything is snappier, overcoming the slow input/output speed of SD cards which significantly limits the RPi. My SATA cable arrived and I got to work, this guide will show you how to partition your SATA hard drive for the Banana Pi, copy the operating system onto the SATA hard drive and configure the SD card to point to the SATA hard drive during the boot process. It works for Raspbian and Bananian (other distros were not tested), I used a Crucial 128GB m4 SSD for this guide.

Setup Linux on Banana Pi SATA Hard Drive

The Banana Pi has the awesome feature over the Raspberry Pi of having a SATA port. I have connected an SSD hard drive to the BAnana Pi and now I run Bananian off the SSD hard drive. It boots in 15-20 seconds :). The Banana Pi has a small power port for SATA hard drives that requires a special cable.

If you don’t have a Banana Pi or just needs the SATA cable, here are some deals that may interest you. Make sure you have a 5 Volt 2 Amp charger to be able to power the SATA. Most phone chargers do not supply the required amps for Pi devices to power themselves and an external hard drive (though USB sticks are usually OK).

Banana Pi Deal
Price
Banana Pi SATA Cable
$2.61
Banana Pi Complete SATA Kit (EU)
$73.99
Banana Pi Complete SATA Kit (US)
$74.99

Manage SATA Partitions

I will assume you ahve already backed up any data on the SATA hard drive. You will be deleting partitions so all of your data will be erased after this process. You have been warned.

SSH in and enter this command to start fdisk

sudo fdisk /dev/sda

You need to delete all existing partitions on the disk
Type d to delete partitions

d

You may have multiple partitions, start with partition 1, input 1 and press enter

Continue for the remaining partitions

Press d then enter

Enter 2, then press enter

Until they are all gone

Write the partition table changes

w

Go back into the partition manager

sudo fdisk /dev/sda

Create a new partition

n

Choose a primary partition

p

Enter Partition number 1

Accept the default start sector, press Enter

Accept default end sector, press Enter

Write the changes to the partition table

w

Back at the terminal prompt, format the disk to ext4 and mount it as /dev/sda1

sudo mke2fs -t ext4 -L rootfs /dev/sda1

Copy Raspbian or Bananian to SATA Hard Drive

Update: Follow these instructions

Now copy the entire contents of the SD card to the SATA

Create a temporary mount point

sudo mkdir /tmp/sata

mount the drive in the /tmp/sata directory

sudo mount /dev/sda1 /tmp/sata

Copy everything in root shown by / to the /tmp/sata directory
It takes about 5 minutes to complete.

sudo rsync -arx --progress / /tmp/sata

Make Banana Pi Boot to the SATA hard drive

For Raspbian, you can jump over this step to editing uEnv.txt

For Bananian you have to mount the boot partition first

sudo mount /dev/mmcblk0p1 /boot

Now edit uEnv.txt to point the root folder to the SATA drive /dev/sda1

sudo nano /boot/uEnv.txt

Do not create any line breaks, in the first line find this snippet

root=/dev/mmcblk0p2

Change it to

root=/dev/sda1

Ctrl+X, Y and Enter to save

sync

Reboot to see if it works

sudo reboot

Now see if the hard drive is being used

df -h

It should show something like this

Filesystem      Size  Used Avail Use% Mounted on
rootfs          118G  1.2G  111G   2% /
/dev/root       118G  1.2G  111G   2% /
devtmpfs        486M     0  486M   0% /dev
tmpfs            98M  256K   97M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           195M     0  195M   0% /run/shm

These directions put together from this post and this post .

If you make any mistakes and it won’t boot, place the SD card in your main machine and edit the uEnv.txt, change root back to its default value and it will boot again

root=/dev/mmcblk0p2