-
Notifications
You must be signed in to change notification settings - Fork 433
Standalone partitioning explained
When using a standalone .img file, this is a complete image of an entire SD card. This means it includes the MBR (storing the partition table) as well as all the raw partitions. This is the most low-level possible way of writing an SD card, but it's the only way to access multiple partitions on an SD card using Windows (via the Win32DiskImager software).
Writing an image like 2014-06-20-wheezy-raspbian.img to an SD card typically creates two partitions:
- A small FAT-format boot partition (which contains the Raspberry Pi firmware, a compiled Linux kernel and some config files).
- A large ext4-format root partition (which contains all the files directly used by Linux, including all the applications and your user's home directory).
Because the partition table (and raw partitions) are copied directly from the .img file to the SD card, it means that the root partition will be the exact size that the .img specifies. This means if your SD card is much larger than the .img file, you'll have a lot of unused space after the end of the root partition. To make use of this unused space you can use a tool like raspi-config to automatically resize the root partition as large as possible.
On the Raspberry Pi, the whole SD card is referred to (by Linux) as /dev/mmcblk0, the first (boot) partition is referred to as /dev/mmcblk0p1 and the second (root) partition is referred to as /dev/mmcblk0p2.
(Similarly, if accessing the SD card on a Linux PC using a USB SD card-reader, the whole card might be /dev/sdb, the first partition would then be /dev/sdb1 and the second partition would be /dev/sdb2. If you have multiple drives connected to your PC, these names might change to /dev/sdc, /dev/sdc1 & /dev/sdc2.)
Unlike a traditional PC, a Raspberry Pi doesn't use any of the bootstrap code stored in the MBR. When the Raspberry Pi is powered on, it instead:
- Loads and runs the
bootcode.binfile from the first partition (/dev/mmcblk0p1) on the SD card, provided the partition has a FAT filesystem. -
bootcode.binin turn then loads and runsstart.elf(andfixup.dat) also from the first partition. -
start.elfthen readsconfig.txtand sets up any GPU configuration requested. -
start.elfthen readscmdline.txtand loads and runskernel.img(the Linux kernel), passing it the entire command-line that it read fromcmdline.txt. (On most standalone Raspberry Pi images the root filesystem is on the second partition, and so there'll be aroot=/dev/mmcblk0p2option somewhere incmdline.txt.) - The loaded Linux kernel then parses the command-line that it was given to determine where its root filesystem is stored (
/dev/mmcblk0p2in most cases). - The Linux kernel then mounts the
/dev/mmcblk0p2partition as the root (/) filesystem, and continues booting the rest of the system from there. - In most cases the
/etc/fstabfile (File System TABle) on the root filesystem will have a line asking for the/dev/mmcblk0p1partition to be mounted at/boot. This means that from within Linux you can then edit/boot/config.txtto modify theconfig.txtfile on the first partition; which will then get read bystart.elfwhen you next reboot the Pi.