People are commonly confused by the difference between three distinct things:
- A random access block storage device such as an SD card (or HDD).
- A storage partition which is a section of a device; there may only be one which occupies pretty much the whole device.
- A filesystem which is something used to organize the data on a partition.
The significance of #2 is that it is defined according to a particular scheme, and this information is stored somewhere on the device separate from the partition itself1. Currently there are two such schemas used predominantly, MBR and GPT. What these primarily implement is a partition table which describes the layout of the partitions on a device.
The partition table may include a clue about what kind of filesystem can be expected to be found in a partition, and thus where most people get most confused is the difference between #2 and #3. They are not synonymous. A partition may be indicated to exist in the partition table, containing a certain kind of filesystem, but this does not mean that the partition actually does contain such a filesystem. For that to be true, the partition must be formatted correctly.
Beware this formatting is distinct from the formatting of the device, which just creates the MBR or GPT style partition table. Some tools (such as
fdisk) may create partitions and tag them as containing a particular kind of filesystem, but they do not create the actual filesystem -- so again, that a partition table lists a partition as being of a certain sort does not make it true!
The partition/filesystem formatting includes information about what and where things like directories and files are. Pi image files generally contain two partitions with two different kinds of filesystem:
A small (usually ~50-60 MB) partition with a FAT32 filesystem. This is the "boot partition" which the hardware loads firmware from, then the firmware loads a bootloader, then the bootloader loads an operating system kernel. Or something along those lines. The Pi hardware requires this partition, and it requires the SD card use an MBR style partition table.
A second, much larger partition containing an ext4 filesystem. This is not required and since it is the OS kernel that accesses it, it could be of any sort. Ext4 is the "native" filesystem used by the linux kernel, although again, it could be many other things. There is a much wider variety of filesystems than there are partitioning schemes.
Can represent either devices or partitions. The image files used to format Raspberry Pi SD cards are usually device images, complete with MBR and multiple partitions. When these are copied block for block onto a physical medium, presto, it is as if someone formatted the device and a set of partitions containing data.
Partitions and filesystems have defined sizes that can be changed, but they still must be defined. Filesystems may contain any amount of data up to their defined size limit.
A 5 GB filesystem requires a partition >= 5GB. If it only contains 100 MB of data, this means 4.9 GB of the filesystem is free, and the partition mostly empty. However, that space must actually exist, or else things start to become complicated in a way that most users will not find entertaining.
The image files distributed for use on the Pi are minimal in size for a couple of obvious reasons:
- So they will fit on as small a card as possible.
- So that people do not waste bandwidth transferring, e.g., 4.9 GB of nothing.
That's why you need to expand first the partition and then the filesystem to fill whatever card you are using (the tools used to do this, such as
raspi-config, do both things at once for you, see here). Recent editions of Raspbian may do this automatically.
1. It is possible to format a device "partitionless", with just one filesystem on it, which is different from a device containing one big partition, but you can't do this with the pi's SD card and it isn't worth further discussion here.