Create Bootable SDCARD/USB
Partitioning and formatting
First identify the device node of the card:
sudo fdisk -l
This will list all the storage devices connected to your PC. Assuming the SD card is connected via USB and is sdb:
export card=/dev/sdb export p=""
First use the "umount" command (notice the different spelling without the 'n') to unmount all the partitions, and then use the "fdisk" command to partition the SD card:
sudo fdisk ${card}
Use the command o to delete all partitions, and then use command n to add new partitions.
Command (m for help): n # Type n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): # Press Enter Key
Using default response p
Partition number (1-4, default 1): # Press Enter Key
Using default value 1
First sector (2048-15523839, default 2048): # Press Enter Key
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-15523839, default 15523839): +20M # Type +20M
Add the second partition
Command (m for help): n
Partition type: # Press Enter Key
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 2): # Press Enter Key
Using default value 2
First sector (43008-15523839, default 43008):
Using default value 43008
Last sector, +sectors or +size{K,M,G} (43008-15523839, default 15523839): # Press Enter Key
Using default value 15523839
Write the partition table into the SD card:
Command (m for help): w # Type w
Format the partition:
sudo mkfs.vfat ${card}${p}1
sudo mkfs.ext4 ${card}${p}2
Bootloader
To be on the safe side, erase the first part of your SD card:
sudo dd if=/dev/zero of=${card} bs=1k count=1023 seek=1
Burn the bootloader into the SD card:
sudo dd if=${u-boot-dir}/u-boot-sunxi-with-spl.bin of=${card} bs=1024 seek=8
where ${u-boot-dir} represents the directory in which the u-boot-sunxi-with-spl.bin is.