Chapter 16. Creating a partition
As a system administrator, you can create new partitions on a disk.
16.1. Considerations before modifying partitions on a disk
This section lists key points to consider before creating, removing, or resizing partitions.
The maximum number of partitions
The number of partitions on a device is limited by the type of the partition table:
On a device formatted with the Master Boot Record (MBR) partition table, you can have either:
- Up to four primary partitions, or
- Up to three primary partitions, one extended partition, and multiple logical partitions within the extended.
On a device formatted with the GUID Partition Table (GPT), the maximum number of partitions is 128. While the GPT specification allows for more partitions by growing the area reserved for the partition table, common practice used by the
partedutility is to limit it to enough area for 128 partitions.
Red Hat recommends that, unless you have a reason for doing otherwise, you should at least create the following partitions:
The maximum size of a partition
The size of a partition on a device is limited by the type of the partition table:
- On a device formatted with the Master Boot Record (MBR) partition table, the maximum size is 2TiB.
- On a device formatted with the GUID Partition Table (GPT), the maximum size is 8ZiB.
If you want to create a partition larger than 2TiB, the disk must be formatted with GPT.
parted utility enables you to specify partition size using multiple different suffixes:
- MiB, GiB, or TiB
Size expressed in powers of 2.
- The starting point of the partition is aligned to the exact sector specified by size.
- The ending point is aligned to the specified size minus 1 sector.
- MB, GB, or TB
Size expressed in powers of 10.
The starting and ending point is aligned within one half of the specified unit: for example, ±500KB when using the MB suffix.
16.2. Partition types
This section describes different attributes that specify the type of a partition.
Partition types or flags
The partition type, or flag, is used by a running system only rarely. However, the partition type matters to on-the-fly generators, such as
systemd-gpt-auto-generator, which use the partition type to, for example, automatically identify and mount devices.
partedutility provides some control of partition types by mapping the partition type to flags. The parted utility can handle only certain partition types: for example LVM, swap, or RAID.
fdiskutility supports the full range of partition types by specifying hexadecimal codes.
Partition file system type
parted utility optionally accepts a file system type argument when creating a partition. The value is used to:
- Set the partition flags on MBR, or
Set the partition UUID type on GPT. For example, the
hfsfile system types set different GUIDs. The default value is the Linux Data GUID.
The argument does not modify the file system on the partition in any way. It only differentiates between the supported flags or GUIDs.
The following file system types are supported:
The only supported local file systems in RHEL 9 are
16.3. Partition naming scheme
Red Hat Enterprise Linux uses a file-based naming scheme, with file names in the form of
Device and partition names consist of the following structure:
This is the name of the directory in which all device files are located. Because partitions are placed on hard disks, and hard disks are devices, the files representing all possible partitions are located in
The first two letters of the partitions name indicate the type of device on which is the partition located, usually
This letter indicates which device the partition is on. For example,
/dev/sdafor the first hard disk,
/dev/sdbfor the second, and so on. In systems with more than 26 drives, you can use more letters. For example,
The final letter indicates the number that represents the partition. The first four (primary or extended) partitions are numbered
4. Logical partitions start at
5. For example,
/dev/sda3is the third primary or extended partition on the first hard disk, and
/dev/sdb6is 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.
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.
16.4. Mount points and disk partitions
In Red Hat Enterprise Linux, each partition is used to form part of the storage necessary to support a single set of files and directories. This is done using the process known as mounting, which associates a partition with a directory. Mounting a partition makes its storage available starting at the specified directory, known as a mount point.
For example, if partition
/dev/sda5 is mounted on
/usr/, that would mean that all files and directories under
/usr/ physically reside on
/dev/sda5. So the file
/usr/share/doc/FAQ/txt/Linux-FAQ would be stored on
/dev/sda5, while the file
/etc/gdm/custom.conf would not.
Continuing the example, it is also possible that one or more directories below
/usr/ would be mount points for other partitions. For instance, a partition
/dev/sda7 could be mounted on
/usr/local, meaning that
/usr/local/man/whatis would then reside on
/dev/sda7 rather than
16.5. Creating a partition with parted
This procedure describes how to create a new partition on a block device using the
- There is a partition table on the disk. For details on how to format the disk, see Creating a partition table on a disk.
- If the partition you want to create is larger than 2TiB, the disk must be formatted with the GUID Partition Table (GPT).
Start the interactive
# parted block-device
Replace block-device with the path to the device where you want to create a partition: for example,
- Replace block-device with the path to the device where you want to create a partition: for example,
View the current partition table to determine if there is enough free space:
- If there is not enough free space, you can resize an existing partition. For more information, see Resizing a partition.
From the partition table, determine:
- The start and end points of the new partition
- On MBR, what partition type it should be.
Create the new partition:
(parted) mkpart part-type name fs-type start end
Replace part-type with with
extendedbased on what you decided from the partition table. This applies only to the MBR partition table.
- Replace name with an arbitrary partition name. This is required for GPT partition tables.
Replace fs-type with any one of
reiserfs. The fs-type parameter is optional. Note that
parteddoes not create the file system on the partition.
Replace start and end with the sizes that determine the starting and ending points of the partition, counting from the beginning of the disk. You can use size suffixes, such as
1.5TiB. The default size megabytes.
Example 16.1. Creating a small primary partition
For example, to create a primary partition from 1024MiB until 2048MiB on an MBR table, use:
(parted) mkpart primary 1024MiB 2048MiB
The changes start taking place as soon as you enter this command, so review it before executing it.
- Replace part-type with with
View the partition table to confirm that the created partition is in the partition table with the correct partition type, file system type, and size:
Use the following command to wait for the system to register the new device node:
# udevadm settle
Verify that the kernel recognizes the new partition:
# cat /proc/partitions
16.6. Setting a partition type with fdisk
This procedure describes how to set a partition type, or flag, using the
- There is a partition on the disk.
Start the interactive
# fdisk block-device
Replace block-device with the path to the device where you want to set a partition type: for example,
- Replace block-device with the path to the device where you want to set a partition type: for example,
View the current partition table to determine the minor partition number:
Command (m for help): print
You can see the current partition type in the
Typecolumn and its corresponding type ID in the
Enter the partition type command and select a partition using its minor number:
Command (m for help): type Partition number (1,2,3 default 3): 2
Optionally, list the available hexadecimal codes:
Hex code (type L to list all codes): L
Set the partition type:
Hex code (type L to list all codes): 8e
Write your changes and exit the
Command (m for help): write The partition table has been altered. Syncing disks.
Verify your changes:
# fdisk --list block-device