Chapter 2. Disk partitions To divide a disk into one or more logical areas, use the disk partitioning utility. It enables separate management of each partition. 2.1. Overview of partitions The hard disk stores information about the location and size of each disk partition in the partition table. Using information from the partition table, the operating system treats each partition as a logical disk. Some of the advantages of disk partitioning include: Reduce the likelihood of administrative oversights of Physical Volumes Ensure sufficient backup Provide efficient disk management Additional resources What are the advantages and disadvantages to using partitioning on LUNs, either directly or with LVM in between? (Red Hat Knowledgebase) 2.2. Comparison of partition table types To enable partitions on a device, format a block device with different types of partition tables. The following table compares the properties of different types of partition tables that you can create on a block device. Note This section does not cover the DASD partition table, which is specific to the IBM Z architecture. Table 2.1. Partition table types Partition table Maximum number of partitions Maximum partition size Master Boot Record (MBR) 4 primary, or 3 primary and 1 extended partition with 12 logical partitions 2 TiB if using 512 b sector drives 16 TiB if using 4 k sector drives GUID Partition Table (GPT) 128 8 ZiB if using 512 b sector drives 64 ZiB if using 4 k sector drives Additional resources Configuring a Linux instance on IBM Z What you should know about DASD 2.3. MBR disk partitions The partition table is stored at the very start of the disk, before any file system or user data. For a more clear example, the partition table is shown as being separate in the following diagrams. Figure 2.1. Disk with MBR partition table As the diagram shows, the partition table is divided into four sections of four unused primary partitions. A primary partition is a partition on a hard disk drive that contains only one logical drive (or section). Each logical drive holds the information necessary to define a single partition, meaning that the partition table can define no more than four primary partitions. Each partition table entry contains important characteristics of the partition: The points on the disk where the partition starts and ends The state of the partition, as only one partition can be flagged as active The type of partition The starting and ending points define the size and location of the partition on the disk. Some of the operating systems boot loaders use the active flag. That means that the operating system in the partition that is marked "active" is booted. The type is a number that identifies the anticipated usage of a partition. Some operating systems use the partition type to: Denote a specific file system type Flag the partition as being associated with a particular operating system Indicate that the partition contains a bootable operating system The following diagram shows an example of a drive with a single partition. In this example, the first partition is labeled as DOS partition type: Figure 2.2. Disk with a single partition Additional resources MBR partition types 2.4. Extended MBR partitions To create additional partitions, if needed, set the type to extended . An extended partition is similar to a disk drive. It has its own partition table, which points to one or more logical partitions, contained entirely within the extended partition. The following diagram shows a disk drive with two primary partitions, and one extended partition containing two logical partitions, along with some unpartitioned free space. Figure 2.3. Disk with both two primary and an extended MBR partitions You can have only up to four primary and extended partitions, but there is no fixed limit to the number of logical partitions. As a limit in Linux to access partitions, a single disk drive allows maximum 15 logical partitions. 2.5. MBR partition types The table below shows a list of some of the most commonly used MBR partition types and hexadecimal numbers to represent them. Table 2.2. MBR partition types MBR partition type Value MBR partition type Value Empty 00 Novell Netware 386 65 DOS 12-bit FAT 01 PIC/IX 75 XENIX root O2 Old MINIX 80 XENIX usr O3 Linux/MINUX 81 DOS 16-bit ⇐32M 04 Linux swap 82 Extended 05 Linux native 83 DOS 16-bit >=32 06 Linux extended 85 OS/2 HPFS 07 Amoeba 93 AIX 08 Amoeba BBT 94 AIX bootable 09 BSD/386 a5 OS/2 Boot Manager 0a OpenBSD a6 Win95 FAT32 0b NEXTSTEP a7 Win95 FAT32 (LBA) 0c BSDI fs b7 Win95 FAT16 (LBA) 0e BSDI swap b8 Win95 Extended (LBA) 0f Syrinx c7 Venix 80286 40 CP/M db Novell 51 DOS access e1 PRep Boot 41 DOS R/O e3 GNU HURD 63 DOS secondary f2 Novell Netware 286 64 BBT ff 2.6. GUID partition table The GUID partition table (GPT) is a partitioning scheme based on the Globally Unique Identifier (GUID). GPT deals with the limitations of the Mater Boot Record (MBR) partition table. The MBR partition table cannot address storage larger than 2 TiB, equal to approximately 2.2 TB. Instead, GPT supports hard disks with larger capacity. The maximum addressable disk size is 8 ZiB, when using 512b sector drives, and 64 ZiB, when using 4096b sector drives. In addition, by default, GPT supports creation of up to 128 primary partitions. Extend the maximum amount of primary partitions by allocating more space to the partition table. Note A GPT has partition types based on GUIDs. Certain partitions require a specific GUID. For example, the system partition for Extensible Firmware Interface (EFI) boot loaders require GUID C12A7328-F81F-11D2-BA4B-00A0C93EC93B . GPT disks use logical block addressing (LBA) and a partition layout as follows: For backward compatibility with MBR disks, the system reserves the first sector (LBA 0) of GPT for MBR data, and applies the name "protective MBR". Primary GPT The header begins on the second logical block (LBA 1) of the device. The header contains the disk GUID, the location of the primary partition table, the location of the secondary GPT header, and CRC32 checksums of itself, and the primary partition table. It also specifies the number of partition entries on the table. By default, the primary GPT includes 128 partition entries. Each partition has an entry size of 128 bytes, a partition type GUID and a unique partition GUID. Secondary GPT For recovery, it is useful as a backup table in case the primary partition table is corrupted. The last logical sector of the disk contains the secondary GPT header and recovers GPT information, in case the primary header is corrupted. It contains: The disk GUID The location of the secondary partition table and the primary GPT header CRC32 checksums of itself The secondary partition table The number of possible partition entries Figure 2.4. Disk with a GUID Partition Table Important For a successful installation of the boot loader onto a GPT disk a BIOS boot partition must be present. Reuse is possible only if the disk already contains a BIOS boot partition. This includes disks initialized by the Anaconda installation program. 2.7. Partition types There are multiple ways to manage partition types: The fdisk utility supports the full range of partition types by specifying hexadecimal codes. The systemd-gpt-auto-generator , a unit generator utility, uses the partition type to automatically identify and mount devices. The parted utility maps out the partition type with flags . The parted utility handles only certain partition types, for example LVM, swap or RAID. The parted utility supports setting the following flags: boot root swap hidden raid lvm lba legacy_boot irst esp palo The parted utility optionally accepts a file system type argument while creating a partition. For a list of the required conditions, see Creating a partition with parted . Use the value to: Set the partition flags on MBR. Set the partition UUID type on GPT. For example, the swap , fat , or hfs file system types set different GUIDs. The default value is the Linux Data GUID. The argument does not modify the file system on the partition. It only differentiates between the supported flags and GUIDs. The following file system types are supported: xfs ext2 ext3 ext4 fat16 fat32 hfs hfs+ linux-swap ntfs reiserfs Note The only supported local file systems in RHEL 8 are ext4 and xfs . 2.8. Partition naming scheme Red Hat Enterprise Linux uses a file-based naming scheme, with file names in the form of /dev/ xxyN . Device and partition names consist of the following structure: /dev/ Name of the directory that contains all device files. Hard disks contain partitions, thus the files representing all possible partitions are located in /dev . xx The first two letters of the partition name indicate the type of device that contains the partition. y This letter indicates the specific device containing the partition. For example, /dev/sda for the first hard disk and /dev/sdb for the second. You can use more letters in systems with more than 26 drives, for example, /dev/sdaa1 . N The final letter indicates the number to represent the partition. The first four (primary or extended) partitions are numbered 1 through 4 . Logical partitions start at 5 . For example, /dev/sda3 is the third primary or extended partition on the first hard disk, and /dev/sdb6 is the second logical partition on the second hard disk. Drive partition numbering applies only to MBR partition tables. Note that N does not always mean partition. Note Even if Red Hat Enterprise Linux can identify and refer to all types of disk partitions, it might not be able to read the file system and therefore access stored data on every partition type. However, in many cases, it is possible to successfully access data on a partition dedicated to another operating system. 2.9. Mount points and disk partitions In Red Hat Enterprise Linux, each partition forms a part of the storage, necessary to support a single set of files and directories. Mounting a partition makes the storage of that partition available, starting at the specified directory known as a mount point . For example, if partition /dev/sda5 is mounted on /usr/ , it means that all files and directories under /usr/ physically reside on /dev/sda5 . The file /usr/share/doc/FAQ/txt/Linux-FAQ resides on /dev/sda5 , while the file /etc/gdm/custom.conf does not. Continuing the example, it is also possible that one or more directories below /usr/ would be mount points for other partitions. For example, /usr/local/man/whatis resides on /dev/sda7 , rather than on /dev/sda5 , if /usr/local includes a mounted /dev/sda7 partition.

Commands: