Bananapi - Boot from SATA

Disclaimer

This procedure still requires the SD card being plugged in. Read the links.

Guide

  • uname -a
Linux bananapi 3.4.108-bananian #2 SMP PREEMPT Thu Aug 13 06:08:25 UTC 2015 armv7l GNU/Linux
  • df -Pah
root@bananapi ~ # df -Pah
Filesystem      Size  Used Avail Use% Mounted on
rootfs             -     -     -    - /
/dev/root       1.8G  931M  743M  56% /
devtmpfs        486M     0  486M   0% /dev
sysfs              0     0     0    - /sys
tmpfs            98M  204K   97M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
proc               0     0     0    - /proc
configfs           0     0     0    - /sys/kernel/config
tmpfs           195M     0  195M   0% /run/shm
devpts             0     0     0    - /dev/pts
  • sudo fdisk /dev/sda
  • d
  • 1
  • 2
  • w
  • sudo fdisk /dev/sda
  • n
  • p
  • 1
  • <ENTER>
  • <ENTER>
  • w
root@bananapi ~ # fdisk /dev/sda

Welcome to fdisk (util-linux 2.25.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
Selected partition 1
Partition 1 has been deleted.

Command (m for help): p

Disk /dev/sda: 111.8 GiB, 120034123776 bytes, 234441648 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: 0x00000000

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

root@bananapi ~ # fdisk /dev/sda

Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

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

Created a new partition 1 of type 'Linux' and of size 111.8 GiB.

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

root@bananapi ~ #
  • sudo mke2fs -t ext4 -L rootfs /dev/sda1
root@bananapi ~ # mke2fs -t ext4 -L rootfs /dev/sda1
mke2fs 1.42.12 (29-Aug-2014)
/dev/sda1 contains a ext4 file system labelled 'rootfs'
        last mounted on / on Fri Jan  1 11:47:21 2016
Proceed anyway? (y,n) y
  • mkdir /tmp/sata
  • mount /dev/sda1 /tmp/sata
  • rsync -arx —progress / /tmp/sata
  • mount /dev/mmcblk0p1 /boot
  • vi /boot/boot.cmd
  • You want to change root=/dev/mmcblk0p2 to root=/dev/sda1 but what screwed me over is that there are actually two entries and you want the second one!
  • :wq!
  • apt-get install -y u-boot-tools
  • mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr
  • vi /etc/fstab
  • /dev/sda1 / ext4 defaults,nodiratime,data=writeback,errors=remount-rw 0 0
  • :wq!
  • sync
  • reboot
  • df -Pah
Filesystem      Size  Used Avail Use% Mounted on
rootfs             -     -     -    - /
/dev/root       111G  1.2G  104G   2% /
devtmpfs        486M     0  486M   0% /dev
sysfs              0     0     0    - /sys
tmpfs            98M  204K   97M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
proc               0     0     0    - /proc
configfs           0     0     0    - /sys/kernel/config
tmpfs           195M     0  195M   0% /run/shm
devpts             0     0     0    - /dev/pts
  • reboot
  • Do the next steps again when you didn't rsync the system after the edit above.
  • vi /etc/fstab
  • /dev/sda1 / ext4 defaults,nodiratime,data=writeback,errors=remount-rw 0 0
  • :wq!
  • apt-get install hdparm
  • hdparm -I /dev/sda | grep TRIM
  • fstrim -v /
  • vi /etc/cron.daily/trim
#!/bin/sh
LOG=/var/log/trim.log
echo "*** $(date -R) ***" >> $LOG
fstrim -v / >> $LOG
  • :wq!
  • chmod +x /etc/cron.daily/trim

Links

Move Linux Banana Pi SATA Setup
Problem pointing boot to hdd
Moving Bananian to SATA HDD
Banana Pi: Boot your rootfs from SATA
TRIM

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.