Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.

NOOBS partitioning explained

Andrew Scheller edited this page Jun 30, 2014 · 8 revisions

NOOBS partitioning (and booting) explained

The multiple partitions that NOOBS divides your SD card into can be quite overwhelming, so hopefully this page will try and explain how it all works, and illustrate how NOOBS differs from the 'traditional' standalone images.

Non-NOOBS partitioning

When using a standalone .img file, this is a complete image of an entire SD card, and thus includes the partition table as well as the raw partitions. Writing an image like 2014-06-20-wheezy-raspbian.img to an SD card typically creates two partitions - a small FAT boot partition (which contains the Raspberry Pi firmware and a Linux kernel) and a large ext4 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 partition) is 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; which is why you normally want to use a tool like raspi-config to resize the root partition after the first bootup, to ensure that all the space on your SD card is available to Linux.

Non-NOOBS bootup

When you switch on your Pi, it first loads bootcode.bin from the FAT partition, which in turn loads start.elf (and fixup.dat). start.elf then reads its configuration from config.txt, and then loads kernel.img, passing it the kernel command-line that's stored in cmdline.txt. kernel.img then boots up Linux, and uses the command-line it was given to determine on which partition the root-filesystem is stored (for a standalone image, this will nearly always be the second partition, i.e. /dev/mmcblk0p2 in Linux-speak), and then loads the rest of the system from the root filesystem.

NOOBS bootup (part 1)

When you first switch on your Pi with a NOOBS card inserted, it first loads bootcode.bin from the FAT partition as normal, but then it finds that start.elf is missing, so it loads recovery.elf instead, which switches the firmware into "NOOBS mode" - it uses recovery.img instead of kernel.img, recovery.cmdline instead of cmdline.txt, and it sets recovery.rfs to be the root filesystem (an initramfs from where the NOOBS GUI application loads).

NOOBS partitioning

If NOOBS detects that this is the first time it's been booted it automatically shrinks the first partition, and creates a new large extended partition and a small settings partition.

This then gives us three primary partitions:

  1. /dev/mmcblk0p1 is the FAT boot (a.k.a. recovery) partition - where the Raspberry Pi always boots from at power-on
  2. /dev/mmcblk0p2 is the extended partition (we'll come back to this later)
  3. /dev/mmcblk0p3 is the ext4 settings partition - this contains files telling NOOBS which OSes are installed and what partitions they're installed on, which OS should be loaded by default, which language/keyboard NOOBS should use, etc.

The reason the settings are stored on a small auxiliary partition rather than on the same /dev/mmcblk0p1 partition as the NOOBS application itself is because of the NOOBS 'prime directive' - "NOOBS never writes to the first FAT partition. FAT partition the first, NOOBS no writee...". By never writing anything to the first partition, this ensures that the first partition can never be corrupted, and thus the NOOBS 'recovery mode' will always be accessible (to allow OSes to be re-installed), no matter what happens to the rest of the SD card.

For historical reasons, SD cards (and hard-drives) can only have a maximum of 4 primary partitions, but to get around that limitation one of those primary partitions can optionally be an extended partition, and that extended partition can contain an unlimited amount of logical partitions inside it. On Linux, the primary partitions are always numbered 1-4 (i.e. /dev/mmcblk0p1 - /dev/mmcblk0p4 on the Pi), and logical partitions are always numbered 5 and above (i.e. /dev/mmcblk0p5 and above on the Pi).

NOOBS bootup (part 2)

If NOOBS detects that no Operating Systems have been installed yet, or if the user is pressing the Shift key, it displays the OS-installation menu, allowing the user to choose which OS(es) to install. Install menu

NOOBS datafiles

In contrast to the standalone images described earlier (which contain raw partitions), NOOBS instead uses (compressed) tarballs of the partition contents, along with a bunch of settings files. NOOBS is responsible for actually creating the partitions itself, which means the partitions are always created at the "correct" size in the first place, there's no need to resize them later. And unlike the low-level raw partitions, the tarballs don't store unused disk blocks.

NOOBS OS installation

For the first example, let's assume that the user is installing just Raspbian. The partitions.json (which can be viewed online here) then specifies which partitions should be created, how big they should be, and which filesystems they should use. In this example it would create a 60MB FAT partition (/dev/mmcblk0p5), format it, and extract the contents of boot.tar.xz to it. As the root partition has 'want_maximised: true' it would then create an ext4 partition (/dev/mmcblk0p6) filling up the entirety of the rest of the extended partition (/dev/mmcblk0p2 described earlier), format it, and extract the contents of root.tar.xz to it. It then runs the partition_setup.sh script which mounts these new partitions, and edits files (typically just cmdline.txt on the boot partition and /etc/fstab on the root partition) to tell Raspbian which partitions it got installed to. And finally it updates the settings partition with details of the OS we just installed.

If instead we were installing Raspbian and ArchLinux then we might end up with ArchLinux's boot partition as /dev/mmcblk0p5, ArchLinux's root partition as /dev/mmcblk0p6, Raspbian's boot partition as /dev/mmcblk0p7 and Raspbian's root partition as /dev/mmcblk0p8. As both Raspbian's and ArchLinux's partitions.json file specify one of their partitions as 'want_maximised: true' then we'd end up with two small root partitions and two large-as-possible root partitions. NOOBS never 'wastes' any space on an SD card.

NOOBS bootup (part 3)

If the user isn't pressing the Shift key, and (using the information stored on the settings partition) NOOBS detects that only one bootable Operating System has been installed, it automatically boots that Operating System. It does this by reading the settings partition to determine the boot partition for that OS, and then instructs the firmware to "soft-reboot" using the OS's boot partition. This then 'reboots' the firmware and loads start.elf from the specified partition (typically /dev/mmcblk0p5 if only one OS is installed) and then proceeds the same as the standalone boot described at the very top of this page - start.elf loads kernel.img and reads cmdline.txt, and then kernel.img uses the command-line that was passed to it to determine which partition the root filesystem is stored on (typically /dev/mmcblk0p6 if only one OS is installed), and loads the rest of the system from there.

If instead multiple Operating Systems have been installed, NOOBS then displays the OS-boot menu, allowing the user to choose which OS(es) to boot. Boot menu Once the user has selected an option (or if the menu times out and defaults to the last-booted option) then the boot proceeds as described immediately above, with NOOBS using the information on the settings partition to determine which partition to "soft-reboot" as the boot partition.

If using the autoboot.txt feature described here then bootcode.bin immediately "soft-reboots" to the specified partition at power-on, and skips loading NOOBS entirely.

Booting RISC OS within NOOBS

The one small caveat to the above is that RISC OS doesn't understand partition tables, and so it has to be installed to a specific partition at a specific offset. This is what the riscos-boot.bin file is for, and why the RISC OS 'root' partition is still stored as a raw partition and not as a tarball. However NOOBS handles all these details for you automatically, and it's still possible to install other OSes alongside RISC OS.

Clone this wiki locally