Run Bananian 16.04 From SATA 2017-07-12
Recently I rebuilt this Banana Pi box and figured I'd follow my own instructions. It went well enough, but I figured I'd keep track of what I did and update this post. Nothing, significant, just some cleanup really.
Run Bananian 16.04 From SATA 2016-05-29
So, I got a Banana Pi. The short story is that at home I have a small server (desktop really) that runs Linux and provides some network services for me... such as DHCP/DNS, Asterisk, and Samba. Currently this stuff runs on an old HP DC7700 desktop with a couple GB of memory and a 1TB SATA drive in it. Not a whole lot of computing power, but it does just fine for what I need. In fact, I was hoping I could do with even less. Less POWER that is! That's where the Banana Pi comes in. It has a GigE network port and a SATA port, which is a big step up from the Raspberry Pi.
The trouble with the bpi is that it can't boot from the SATA drive. This is irritating because SD cards are typically much smaller than SATA drives, they are generally more delicate than SATA drives, and they are sadly much slower than SATA drives. It is however possible to run your OS from the SATA drive, as long as you keep your /boot on a small SD card just to get it started. You don't have to write to the SD card either, which helps deal with their somewhat limited lifespan too. I had tried out a few OS's on my bpi and seemed to like Bananian. The current version is 16.04 and I set out to migrate it to my SATA drive.
The trouble is, a lot of the instructions I found seem to be for an earlier version of Bananian or possibly for Raspbian. They refer to /boot/uEnv.txt which does not exist in Bananian 16.04. There were a few folks who went around adding comments to these posts explaining that the procedure was slightly different... but I didn't see where anyone had actually collected the information together and made a Bananian v16.04 SATA migration instruction set. So here is what I did to make it work. Note that I am writing these instructions from the perspective of root because Bananian comes with only a root user by default, and if you are going to run Bananian from SATA you should do this stuff before setting up your OS, such as setting up users.
Start with a fresh [working] install of Bananian. Shut down your bpi and hook up your SATA drive. Boot it, and check to make sure the drive is recognized (should show up as /dev/sda).
make sure you're up to date
# apt-get update
# apt-get upgrade
Remove all partitions on your SATA drive and create a single primary partition that takes up the whole drive.
# fdisk /dev/sda
<enter> * repeat for each pre-existing partition
Then give it a file system.
# mke2fs -t ext4 -L rootfs /dev/sda1
Now mount it and copy the OS files to it.
# mkdir /tmp/sata
# mount /dev/sda1 /tmp/sata
# rsync -arx --progress / /tmp/sata
Now tell it to boot from the SATA drive.
# mount /dev/mmcblk0p1 /boot
# cd /boot
# nano boot.cmd
In the boot.cmd file you need to replace root=/dev/mmcblk0p2 with root=/dev/sda1, then save the file and exit, then make a new boot.scr.
# apt-get install u-boot-tools
# rm boot.scr
# mkimage -C none -A arm -T script -d boot.cmd boot.scr
Finally, restart your bpi and check out your drive.
# df -h