Quick Summary:
$this->bbcode_list('1')
Detailed Instructions:
This will use examples for installing /tmp/archlinux-hf-2013-07-22.img. The SD card shows up as /dev/sdj. This will overwrite the SD card, so all information will be wiped from the card. All these steps are run as root.
$this->bbcode_list('1')
$this->bbcode_second_pass_code('', '
# losetup /dev/loop3 /tmp/archlinux-hf-2013-07-22.img
# parted /dev/loop3 unit b print free
')
For the archlinux-hf-2013-07-22.img, you should see
$this->bbcode_second_pass_code('', '
Model: Loopback device (loopback)
Disk /dev/loop3: 1960837120B
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
16384B 1048575B 1032192B Free Space
1 1048576B 95420415B 94371840B primary fat16 lba
2 95420416B 1877999615B 1782579200B extended
5 96468992B 1877999615B 1781530624B logical ext4
1877999616B 1960837119B 82837504B Free Space
')
You'll use the start offset of partition 1 and partition 5 to setup lookback devices for those partitions.
$this->bbcode_second_pass_code('', '
# dd if=/dev/loop3 of=/dev/sdj bs=1M count=2
')
$this->bbcode_second_pass_code('', '
# parted /dev/sdj
mklabel msdos
unit b
mkpart p fat16 1048576 95420415
mkpart e 95420416 1030225919
mkpart l ext4 96468992 1030225919
quit
')
You'll now notice the /dev/sdj1 and /dev/sdj5 device nodes.
$this->bbcode_second_pass_code('', '
# losetup /dev/loop4 /tmp/archlinux-hf-2013-07-22.img -o 1048576
# dd if=/dev/loop4 /dev/sdj1 bs=512 count=184320
')
Note: 512 * 184320 = 94371840 (the size of the first partition).
$this->bbcode_second_pass_code('', '
# mkfs.ext4 /dev/sdj5
# losetup /dev/loop5 /tmp/archlinux-hf-2013-07-22.img -o 96468992
# mkdir /tmp/src /tmp/dest
# mount -r /dev/loop5 /tmp/src
# mount /dev/sdj5 /tmp/dest
# cp -a /tmp/src/. /tmp/dest/.
# umount /tmp/dest
# umount /tmp/src
')
$this->bbcode_second_pass_code('', '
# losetup -d /dev/loop3 /dev/loop4 /dev/loop5
')
Anyone know how much of the boot sector needs to be copied without blowing away the whole partition table? I don't know the requirements for u-boot.