This document explains how to prepare a MicroSD card for installing Arch Linux ARM on Cubieboard A10 using a Linux distro terminal.
Briefly you will need to erase everything (partition table and data) from the card, partition and format.
Please be very careful as the following commands may damage an entire drive that you might have attached to your PC if you're careless.
- Card reader
- MicroSD with at least 2GB (recommended 4GB)
- MicroSD to SD adapter.
- Root access.
2 to 5 min
Before you enter the card list all the connected drives:
~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 119,2G 0 disk
├─sda1 8:1 0 115,5G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 3,8G 0 part [SWAP]
Now insert the card and run the same command again:
~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 119,2G 0 disk
├─sda1 8:1 0 115,5G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 3,8G 0 part [SWAP]
sdb 8:16 1 7,7G 0 disk
└─sdb1 8:17 1 7,7G 0 part /media/tiberiu/MicroSD
You have to compare the two results and if not sure look at the size. In my case the drive that I will work with is sdb
because one partition of sda is mounted as root and it is in bouth results.
~# umount /media/tiberiu/MicroSD
Replace sdb
with your drive but think twice before you do it because this command is ireversible.
~# dd if=/dev/zero of=/dev/sdb bs=1M count=1
1+0 records in
1+0 records out
1048576 bytes (1,0 MB) copied, 0,00389601 s, 269 MB/s
The card needs to be devided in 3 parts:
- First the bootable sector - a small space (1MB) starting from the very first sector of the drive unpartitioned, here will go the boot script;
- A FAT 16 partition with at least 16MB which will store the environment configurations, device mappings and the kernel needed only for the boot;
- The rest of the drive partitioned in Linux file system for the rootfs, here will be store the actual system files, the ones that are going to be mounted on root:
/
.
I'm going to use fdisk command for this task, replace sdb
with your drive
~# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x965271bf.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help):
Now type p
and enter, this will list the partition table, if in the result you have under Device Boot ...
something than you piked the wrong drive, you should abort and start over.
Command (m for help): p
Disk /dev/sdb: 8270 MB, 8270118912 bytes
255 heads, 62 sectors/track, 1021 cylinders, total 16152576 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
Disk identifier: 0x965271bf
Device Boot Start End Blocks Id System
Create the boot partition (where the boot files will go) and size it to at least 16Mb (recommended 32Mb), also, first partition has to start after 1Mb of empty space.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-16152575, default 2048): 2048
Last sector, +sectors or +size{K,M,G} (2048-16152575, default 16152575): +32M
Set the type flag to e
- W95 FAT16 (LBA) :
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): e
Changed system type of partition 1 to e (W95 FAT16 (LBA))
Create the file system drive using the defaults suggested by fdisk.
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 2):
Using default value 2
First sector (67584-16152575, default 67584):
Using default value 67584
Last sector, +sectors or +size{K,M,G} (67584-16152575, default 16152575):
Using default value 16152575
Set the type flag for the second partition to 83
- Linux
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 83
Recap by listing the partition table :
Command (m for help): p
Disk /dev/sdb: 8270 MB, 8270118912 bytes
255 heads, 62 sectors/track, 1021 cylinders, total 16152576 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
Disk identifier: 0xd4dcaa3d
Device Boot Start End Blocks Id System
/dev/sdb1 2048 67583 32768 e W95 FAT16 (LBA)
/dev/sdb2 67584 16152575 8042496 83 Linux
If your result looks similar you're good to go. So far the changes in fdisk are just in memory, double check and write them with w
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
We check now the results by listing the drives
~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 119,2G 0 disk
├─sda1 8:1 0 115,5G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 3,8G 0 part [SWAP]
sdb 8:16 1 7,7G 0 disk
├─sdb1 8:17 1 32M 0 part
└─sdb2 8:18 1 7,7G 0 part
If you don't see the new created partition, in my example sdb1 and sdb2, pull out/plug in the card.
To format the partitions mkfs.*
will be used, again with root permissions.
Replace sdb
with your selected drive.
For the first partition mkfs.vfat
:
~# mkfs.vfat /dev/sdb1
mkfs.vfat 3.0.16 (01 Mar 2013)
For the second partition mkfs.ext4
:
~# mkfs.ext4 /dev/sdb2
mke2fs 1.42.8 (20-Jun-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
502944 inodes, 2010624 blocks
100531 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2059403264
62 block groups
32768 blocks per group, 32768 fragments per group
8112 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
Now your card is ready, if you list again the drives you should have something similar with this :
~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 119,2G 0 disk
├─sda1 8:1 0 115,5G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 3,8G 0 part [SWAP]
sdb 8:16 1 7,7G 0 disk
├─sdb1 8:17 1 32M 0 part
└─sdb2 8:18 1 7,7G 0 part