5 | | Copy BOOT.BIN and image.ub to first partition, then boot. |
| 5 | My version: |
| 6 | |
| 7 | Find the device name. For my Lenovo laptop with built-in card reader, it's {{{/dev/mmcblk0}}}. |
| 8 | Partitions are {{{/dev/mmcblk0p1}}} etc. Unmount the card if mounted. |
| 9 | |
| 10 | '''Erase the first sector''' |
| 11 | |
| 12 | {{{ |
| 13 | $ dd if=/dev/zero of=/dev/xxxx bs=1024 count=1 |
| 14 | }}} |
| 15 | |
| 16 | '''Calculate {{{new_cylinders}}} |
| 17 | |
| 18 | {{{ |
| 19 | $ fdisk -l /dev/xxxx |
| 20 | |
| 21 | Disk /dev/sdb: 8068 MB, 8068792320 bytes |
| 22 | 249 heads, 62 sectors/track, 1020 cylinders, total 15759360 sectors |
| 23 | Units = sectors of 1 * 512 = 512 bytes |
| 24 | Sector size (logical/physical): 512 bytes / 512 bytes |
| 25 | I/O size (minimum/optimal): 512 bytes / 512 bytes |
| 26 | Disk identifier: 0x00000000 |
| 27 | |
| 28 | Disk /dev/sdb doesn't contain a valid partition table |
| 29 | }}} |
| 30 | |
| 31 | Note the size in bytes (i.e. 8068792320). Calculate: |
| 32 | |
| 33 | {{{new_cylinders = size_in_bytes/8225280}}} |
| 34 | |
| 35 | (round down). For this 8Gb example the result is 980. |
| 36 | |
| 37 | '''Partition the card''' |
| 38 | |
| 39 | Creat one 200MB FAT32 partition and the remainder as ext2 |
| 40 | (ext4 should work too). First, have to set CHS correctly. |
| 41 | |
| 42 | {{{ |
| 43 | $ fdisk /dev/xxxx |
| 44 | }}} |
| 45 | |
| 46 | (delete any existing partitions; shouldn't be any) |
| 47 | |
| 48 | {{{ |
| 49 | Command (m for help): x |
| 50 | Expert command (m for help): h |
| 51 | Number of heads (1-256, default 30): 255 |
| 52 | Expert command (m for help): s |
| 53 | Number of sectors (1-63, default 29): 63 |
| 54 | Expert command (m for help): c |
| 55 | Number of cylinders (1-1048576, default 2286): <new_cylinders calculated from above> |
| 56 | Expert command (m for help): r |
| 57 | }}} |
| 58 | |
| 59 | Now create partitions: |
| 60 | |
| 61 | {{{ |
| 62 | Command (m for help): n |
| 63 | Partition type: |
| 64 | p primary (0 primary, 0 extended, 4 free) |
| 65 | e extended |
| 66 | Select (default p): p |
| 67 | Partition number (1-4, default 1): 1 |
| 68 | First sector (2048-15759359, default 2048): |
| 69 | Using default value 2048 |
| 70 | Last sector, +sectors or +size{K,M,G} (2048-15759359, default 15759359): +200M |
| 71 | |
| 72 | Command (m for help): n |
| 73 | Partition type: |
| 74 | p primary (1 primary, 0 extended, 3 free) |
| 75 | e extended |
| 76 | Select (default p): p |
| 77 | Partition number (1-4, default 2): 2 |
| 78 | First sector (411648-15759359, default 411648): |
| 79 | Using default value 411648 |
| 80 | Last sector, +sectors or +size{K,M,G} (411648-15759359, default 15759359): |
| 81 | Using default value 15759359 |
| 82 | }}} |
| 83 | |
| 84 | Set bootable flag, partition types: |
| 85 | |
| 86 | {{{ |
| 87 | Command (m for help): a |
| 88 | Partition number (1-4): 1 |
| 89 | |
| 90 | Command (m for help): t |
| 91 | Partition number (1-4): 1 |
| 92 | Hex code (type L to list codes): c |
| 93 | Changed system type of partition 1 to c (W95 FAT32 (LBA)) |
| 94 | |
| 95 | Command (m for help): t |
| 96 | Partition number (1-4): 2 |
| 97 | Hex code (type L to list codes): 83 |
| 98 | }}} |
| 99 | |
| 100 | Check table and write changes: |
| 101 | |
| 102 | {{{ |
| 103 | Command (m for help): p |
| 104 | |
| 105 | Disk /dev/sdb: 8068 MB, 8068792320 bytes |
| 106 | 249 heads, 62 sectors/track, 1020 cylinders, total 15759360 sectors |
| 107 | Units = sectors of 1 * 512 = 512 bytes |
| 108 | Sector size (logical/physical): 512 bytes / 512 bytes |
| 109 | I/O size (minimum/optimal): 512 bytes / 512 bytes |
| 110 | Disk identifier: 0x920c958b |
| 111 | |
| 112 | Device Boot Start End Blocks Id System |
| 113 | /dev/sdb1 * 2048 411647 204800 c W95 FAT32 (LBA) |
| 114 | /dev/sdb2 411648 15759359 7673856 83 Linux |
| 115 | |
| 116 | Command (m for help): w |
| 117 | The partition table has been altered! |
| 118 | |
| 119 | Calling ioctl() to re-read partition table. |
| 120 | |
| 121 | WARNING: If you have created or modified any DOS 6.x |
| 122 | partitions, please see the fdisk manual page for additional |
| 123 | information. |
| 124 | Syncing disks. |
| 125 | }}} |
| 126 | |
| 127 | '''Create filesystems''' |
| 128 | |
| 129 | {{{ |
| 130 | mkfs.vfat -F 32 -n boot /dev/sdX1 |
| 131 | mkfs.ext4 -L root /dev/sdX2 |
| 132 | }}} |
| 133 | |
| 134 | '''Mount boot partition''' |
| 135 | |
| 136 | {{{ |
| 137 | mkdir -p /mnt/boot |
| 138 | mount /dev/sdX1 /mnt/boot |
| 139 | }}} |
| 140 | |
| 141 | '''Copy required files''' |
| 142 | {{{ |
| 143 | cp BOOT.BIN /mnt/boot |
| 144 | cp image.ub /mnt/boot |
| 145 | umount /mnt/boot |
| 146 | }}} |