Sunday, 31 August 2014

HummingBoard: Boot your rootfs from mSATA

The HummingBoard-i2eX version has an onboard mSATA II connector. This layout provides you the easiest way to hook up an SSD. All you need is an mSATA Drive. Just plug the drive into the mSATA slot on the back of the Hummingboard and the job is done!

The next step is to move your rootfs to the SSD to unleash the extra SSD power.

Move the rootfs to a SATA Drive

It’s impossible to boot from a SATA drive without an SD card, you will still need a small SD card for the bootloader. However, it is possible to adjust the bootscript (which is similar to a bootloader) on the SD card so that it points directly to your SATA drive. This way your system will boot the OS right from the SATA drive.

Here’s what you have to do:

Note: all this commands require root privileges.
  1. run sudo fdisk -l and identify your SATA drive. In this example /dev/sda represents the SATA disk.
  2. Prepare your disk
    > sudo fdisk /dev/sda
    Delete all partitions using the “d” option
    Create a new primary partition using the “n” option (you can accept all the defaults)
    Use the “w” option the apply the changes.
    Format the partition for rootfs with EXT4 filesystem
    > mkfs.ext4 /dev/sda1

Copying Rootfs

I still assume that /dev/sda represent the SATA drive
> mkdir /tmp/source /tmp/target
> sudo mount /dev/mmcblk0p2 /tmp/source
> sudo mount /dev/sda1 /tmp/target
> (cd /tmp/source; sudo tar --backup -c *) |sudo tar -C /tmp/target -xv
Change the kernel parameters in order to boot from the SSD drive
> mkdir /tmp/boot
> sudo mount /dev/mmcblk0p1 /tmp/boot
> sudo vim /tmp/boot/uEnv.txt
Change the last line to:
.. root=/dev/sda1 ...
Sync to disk and reboot to your hard drive
> sync
> reboot 
You can test the result with: df -h