Banana Pi USB as Boot Device

From KlavoWiki
Jump to navigationJump to search

To use an External USB hard disk or a SATA drive directly connected to the eSATA port follow the following steps. You can not remove the SD card as the bPi needs to initially boot form the SD card but form that moment forward all activity is from the external hard disks.

The following instructions works on image 1604.


Partition and Copy Data to External Drive

Crate an ext4 partition on your external device. Mount the partition and copy the data from the inbuilt card to the external hard disks.

Assuming /mnt is where you have mounted your new partition.

rsync -axv / /mnt

The current root system should now be duplicated to the external drive.

Boot Config

Mount partition 1 from the SD card.

mount /dev/mmcblk0p1 /boot

Install u-boot-tools

apt-get install -y u-boot-tools

Edit boot file

vi /boot/boot.cmd

Look for two location of wording for:

root=/dev/mmcblk0p2

and change it to the partition of your external device.

root=/dev/sda2

Once the file has been modified you need to compile the file for u-boot

mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr

Once this has been done you should be able to reboot and the external drive be the active root partition.

Original boot.cmd File

My original file as reference

#--------------------------------------------------------------------------------------------------------------------------------
# Boot loader script to boot with different boot methods for old and new kernel
# Credits: https://github.com/igorpecovnik - Thank you for this great script!
#--------------------------------------------------------------------------------------------------------------------------------
if load mmc 0:1 0x00000000 uImage-next
then
# mainline kernel >= 4.x
#--------------------------------------------------------------------------------------------------------------------------------
setenv bootargs console=ttyS0,115200 console=tty0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
load mmc 0:1 0x49000000 dtb/${fdtfile}
load mmc 0:1 0x46000000 uImage-next
bootm 0x46000000 - 0x49000000
#--------------------------------------------------------------------------------------------------------------------------------
else
# sunxi 3.4.x
#--------------------------------------------------------------------------------------------------------------------------------
setenv bootargs console=ttyS0,115200 console=tty0 console=tty1 sunxi_g2d_mem_reserve=0 sunxi_ve_mem_reserve=0 hdmi.audio=EDID:0 disp.screen0_output_mode=EDID:1680x1050p60 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
setenv bootm_boot_mode sec
load mmc 0:1 0x43000000 script.bin
load mmc 0:1 0x48000000 uImage
bootm 0x48000000
#--------------------------------------------------------------------------------------------------------------------------------
fi