User:Zulu Foxtrott/ARM64/Blocks/Disks

Partition tables
Although it is theoretically possible to use a raw, unpartitioned disk to house a Linux system (when creating a btrfs RAID for example), this is almost never done in practice. Instead, disk block devices are split up into smaller, more manageable block devices. On systems, these are called partitions. The current standard partitioning technology is GPT, whereas older systems might still use MBR (Master boot record, sometimes also called DOS disklabel).

GPT
The GPT (GUID Partition Table) setup uses 64-bit identifiers for the partitions, which means there is practically no limit on the amount of partitions for a GPT disk. Also the size of a partition is bounded only by a quite big limit (almost 8 ZiB - yes, zebibytes).

GPT also takes advantage of checksumming and redundancy. It carries CRC32 checksums to detect errors in the header and partition tables and has a backup GPT at the end of the disk. This backup table can be used to recover damage of the primary GPT near the beginning of the disk.

Default partitioning scheme
Throughout the remainder of the handbook, the following partitioning scheme will be used as a simple example layout:

What is the firmware partition?
Some target systems expect the firmware (the software that performs the first steps of hardware initialization upon powering on the system) to be present on the storage device of choice itself as they don't ship with this software preinstalled. In contrast to that, legacy and more traditional hardware usually comes with its firmware (also known as BIOS or UEFI) stored in read-only memory (ROM).

Depending on the target system the firmware is usually provided by the hardware vendor/manufacturer. However, for a growing - but still small - number of systems opensource U-Boot can provide the same functionality in form of the (Tertiary Program Loader) and the  (Secondary Program Loader).

Such partitions are not always necessary, but considering the low space consumption and the difficulties we have with documenting the plethora of partitioning differences otherwise, it is recommended to create it in either case.

What is the bootloader partition?
On systems that are supported by mainline U-Boot, this is the partition where U-Boot Proper - the main U-Boot program - itself is installed.

Again, such partitions are not always necessary, but they don't waste resources anyways.

What is the EFI System Partition (ESP)?
When installing Gentoo on a system that uses UEFI to boot the operating system (instead of BIOS), then it is important that an EFI System Partition (ESP) is created. The instructions for below contain the necessary pointers to correctly handle this operation.

The ESP must be a FAT variant (sometimes shown as vfat on Linux systems). The official UEFI specification denotes FAT12, 16, or 32 filesystems will be recognized by the UEFI firmware, although FAT32 is recommended for the ESP. Proceed in formatting the ESP as FAT32:

The EFI system partition is not required when the target system is supported by mainline U-Boot.

Default Btrfs filesystem layout
Throughout the remainder of the handbook, the following layout for the filesystem on will be used as a simple example layout:

If this suffices, immediately jump to Using parted to partition the disk.

Before going to the creation instructions, the first set of sections will describe in more detail how to use Btrfs subvolumes to organize data and how, alternatively, partitioning schemes can be created and what some common pitfalls are.

Using parted to partition the disk
is a partitioning utility and was one of the first Linux block device management utilities to support GPT partitions.

In this chapter, the example partition layout mentioned earlier in the instructions will be used:

Change the partition layout according to personal preference.

Viewing the current partition layout with parted
The application offers a simple interface for partitioning the disks and supports very large partitions (more than 2 TB). Fire up against the disk (in our example, we use ). It is recommended to ask to use optimal partition alignment:

Alignment means that partitions are started on well-known boundaries within the disk, ensuring that operations on the disk from the operating system level (retrieve pages from the disk) use the least amount of internal disk operations. Misaligned partitions might require the disk to fetch two pages instead of one even if the operating system asked for a single page.

To find out about all options supported by parted, type and press return.

Setting the GPT label
Most disks on the or  architectures are prepared using an msdos label. Using, the command to put a GPT label on the disk is :

To have the disk with MBR layout, use.

Removing all partitions with parted
If this isn't done yet (for instance through the operation earlier, or because the disk is a freshly formatted one), first remove all existing partitions from the disk. Type to view the current partitions, and  where   is the number of the partition to remove.

Do the same for all other partitions that aren't needed. However, make sure to not make any mistakes here - parted executes the changes immediately (unlike which stages them, allowing a user to "undo" his changes before saving or exiting fdisk).

Creating the partitions
Now will be used to create the partitions with the following settings:


 * The partition type to use. This usually is primary. If the msdos partition label is used, keep in mind that there can be no more than 4 primary partitions. If more than 4 partitions are needed, make one of the first four partitions extended and create logical partitions inside it.
 * The start location of a partition (which can be expressed in MB, GB, ...)
 * The end location of the partition (which can be expressed in MB, GB, ...)

First, tell parted that the size unit we work with is megabytes (actually mebibytes, abbreviated as MiB which is the "standard" notation, but we will use MB in the text throughout as it is much more common):

Now create a 2 MB partition that will be used by the GRUB2 boot loader later. Use the command for this, and inform  to start from 1 MB and end at 3 MB (creating a partition of 2 MB in size).

Do the same for the boot partition (128 MB), swap partition (in the example, 512 MB) and the root partition that spans the remaining disk (for which the end location is marked as -1, meaning the end of the disk minus one MB, which is the farthest a partition can go).

When using the UEFI interface to boot the system (instead of BIOS), mark the boot partition as the EFI System Partition. Parted does this automatically when the boot option is set on the partition:

The end result looks like so:

Use the command to exit parted.

With partitioning completed, jump down to the section on creating file systems.

With the partitions created, it is now time to put filesystems on them.