FAQ Partitions

From embeddedTS Manuals

Question: Can you provide a breakdown of the partitioning scheme and filesystem of a typical SD Card Image

Answer:

This question is better answered in the individual product pages. The answer provided here is for overview purposes only and may contain outdated information. Refer to your product's specific wiki page for up to date information.

There are two main types of images from which most SD card images can be derived: 1) with the development partition and 2) without it. Generally, the image with a development partition is 2GB and the other is 512MB. Each has the same number of partitions, which is important because the bootloader looks for partition 2, jumps in, and starts executing the kernel. The kernel looks for the initial ramdisk (initrd) on partition 3. The initrd looks for drivers/Debian on partition 4. Shown below are two graphics that give an overall look at the partition scheme for each.


Within the 2GB image, there is a 1.25GB partition which contains all sources and programs for development, including Eclipse IDE, kernel sources, utility sources, etc. specific to your board. In contrast, the 512MB image only contains a 'dummy' partition. This is to keep the four partition layout that is important to the bootloader as mentioned above. This partition has been formatted FAT32 and is first so that you may access these files on a Windows box.

The kernel, initrd, and Debian filesystem partitions between the two cards are practically identical. The first difference you might notice are the difference in partition size (512MB vs 473MB). This is the partition space, not the amount of space taken up by the Debian filesystem, which takes up about 344.75MB. You can take a 512MB image, write it to a 2GB+ image without any modifications, and boot successfully from it.

When plugged into a Linux box and issuing the 'fdisk -l' command within the terminal (or by opening gparted), you will be able to recognize the entire SD card most likely as /dev/sdb. The partitions can be recognized as:

/dev/sdb1 -- FAT32 Development/Dummy Partition
/dev/sdb2 -- NonFS Kernel Partition
/dev/sdb3 -- NonFS Initrd/Busybox Filesystem
/dev/sdb4 -- JFS/EXT3 Debian Filesystem

The kernel is of Non Filesystem type since it only holds a binary executable called "Image" (capital "I"). The kernel will start executing code and then reach for an initial ramdisk image. It finds this on partition 3 along with the linuxrc init script. The initial ramdisk first loads essential drivers and then provides the user with a command prompt. All of this happens within 3 seconds or so.
The command prompt is provided by the busybox program which resides in '/bin'. This single busybox binary is a swiss army knife containing many of the unix-type commands you're used to: ls, cd, mkdir, mount, etc... Use 'busybox --help' for a list of commands which were configured and included within the busybox binary. All commands run within the initrd are symbolic links to the busybox binary. Use 'ls -la /bin' to see these links. You may also notice by running 'ls -la /' that many of the directories such as /lib, /etc, /usr, etc are also symbolic links. These point to partition 4 which contains the Debian filesystem.
From the initrd, you may 'exit' to the Debian filesystem by using the command 'exit'. This will exit the busybox shell and begin the initialization and booting of Debian. You can then use all of the commands that you would normally use on a full-fledged Linux PC, like 'apt-get install'.