Formatting a new SD card

From RidgeRun Developer Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.


Formatting a new SD card

This guide shows you how to create an EXT3 filesystem on a new SD card using a linux host computer with an SD card reader.

Discovering the SD card device

Before you plug in the SD card into the reader, run this command in a terminal.

$ watch "dmesg | tail -10"

Now insert the SD card into the reader and observe the messages in the terminal window.

[11599.200739] sd 3:0:0:0: [sdc] 7744512 512-byte logical blocks: (3.96 GB/3.69
GiB)
[11599.204630] sd 3:0:0:0: [sdc] Assuming drive cache: write through
[11599.210491] sd 3:0:0:0: [sdc] Assuming drive cache: write through
[11599.210495]  sdc:

Use CTRL-C to exit from the watch command and get your prompt back. The SD card device is /dev/sdc, per these messages. The actual device will likely vary on your system.

Unmount and delete any partitions

You might be reusing an SD card that already contains formatted partitions. To discover any partitions:

$ ls -a /dev | grep sdc
/dev/sdc
/dev/sdc1
/dev/sdc2

$

If you see devices with integer number suffixes, these are formatted partitions. You can unmount them using the following commands.

$ sudo umount /dev/sdc1
$ sudo umount /dev/sdc2

You can then use the 'parted' utility to delete them (CAUTION - you are permanently deleting them, make sure you know what you are doing!).

$ sudo parted /dev/sdc rm 1
$ sudo parted /dev/sdc rm 2

Create a new, single partition that encompasses the entire SD card

To create this partition we will again use parted.

$ sudo parted /dev/sdc mkpart primary ext3 0 100%

This will create a single partition that takes up the entire SD card. To create the ext3 filesystem on the partition:

$ sudo mkfs -V -t ext3 /dev/sdc1
mkfs (util-linux-ng 2.16)
mkfs.ext3 /dev/sdc1 
mke2fs 1.41.9 (22-Aug-2009)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
242400 inodes, 967908 blocks
48395 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=994050048
30 block groups
32768 blocks per group, 32768 fragments per group
8080 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

You now should have a formatted ext3 partition on your SD card.

See also:

Installing the Filesystem to an SD Card
Configuring the Avnet S6-OMAP board to use an SD Card root filesystem
Getting Started Guide for the AVNET OMAPL138 EVM