Partitioning means dividing a disk into logical sections before creating a file system on it. It is the step that follows identifying the disk and comes before formatting. This guide shows how to choose between MBR and GPT, create a table then partitions with parted, and check the result. All commands were run on an AlmaLinux test disk; the outputs are real.
What you will learn
- Choose between MBR and GPT depending on the hardware
- Create a partition table then partitions with
parted - Check the layout with
parted printandlsblk - Know where
fdiskandgdiskremain relevant
Prerequisites
sudoaccess and an unmounted disk to prepare (never the system disk)- Having identified the right disk with
lsblk
Why partition
Dividing a disk serves to isolate uses. Separating /home, /var or /data from the root system brings three concrete benefits:
- Isolation: logs filling
/vardo not stop the root system from working if/varis on its own partition. - Security: a dedicated partition can receive restrictive mount options in
/etc/fstab(noexec,nosuid,nodev), useful on/tmpor/home. - Targeted backup: back up or restore
/homewithout touching the rest.
In practice, on a modern server, flexibility is often delegated to LVM on top of one or two partitions, rather than to a frozen layout of many partitions.
Partition table: MBR or GPT
Before any partition, the disk needs a partition table, the structure that describes how the disk is divided. Two formats coexist, and the choice is structuring because it is made before everything else.
| Feature | MBR (msdos) | GPT |
|---|---|---|
| Primary partitions | 4 maximum | 128 (common usage) |
| Disk size handled | 2 TiB | far beyond |
| Firmware | Legacy BIOS | UEFI (and BIOS) |
| Table redundancy | no | yes (backup copy) |
In 2026, GPT is the default choice: it is required beyond 2 TiB, essential with UEFI (the modern firmware that replaces the BIOS), and more robust thanks to its backup table. Keep MBR only for old systems without UEFI. On GPT with UEFI, a small EFI System Partition (ESP, formatted as FAT32, mounted on /boot/efi, about 512 MiB) holds the boot files.
Create a table and partitions with parted
parted handles MBR as well as GPT and is used on the command line (-s mode to script without interactive confirmation). Start with the table:
sudo parted -s /dev/sda mklabel gptThen create the partitions by giving a name, a file system type (only a hint for parted, the real formatting comes later) and the bounds. Here, three partitions: 3 GiB, 2 GiB, then all the rest for LVM:
sudo parted -s /dev/sda mkpart data1 ext4 1MiB 3GiBsudo parted -s /dev/sda mkpart data2 xfs 3GiB 5GiBsudo parted -s /dev/sda mkpart lvm 5GiB 100%The first partition starts at 1 MiB and not at 0: this 1 MiB alignment is the convention that ensures good performance on SSDs and modern arrays. parted applies it automatically.
Check the layout
parted print shows the table created. It is the immediate check after each change:
sudo parted /dev/sda printModel: QEMU QEMU HARDDISK (scsi)Disk /dev/sda: 10.7GBPartition Table: gpt
Number Start End Size File system Name Flags 1 1049kB 3221MB 3220MB data1 2 3221MB 5369MB 2147MB data2 3 5369MB 10.7GB 5368MB lvmThe File system column is empty: the partitions exist but are not formatted yet. lsblk confirms the tree with rounded sizes:
lsblk /dev/sdaNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTSsda 8:0 0 10G 0 disk├─sda1 8:1 0 3G 0 part├─sda2 8:2 0 2G 0 part└─sda3 8:3 0 5G 0 partfdisk and gdisk: when to prefer them
parted covers most needs, but two interactive tools keep their place:
fdisk: the historical editor, now fully GPT compatible. Interactively,ncreates a partition,ddeletes one,pprints,wwrites the changes. Handy for step-by-step exploration.sudo fdisk -llists all the tables of the system.gdisk: afdiskequivalent specialised in GPT, with fine-grained handling of partition types (GUID codes). Useful for advanced GPT manipulations. Beware, it is not installed on RHEL and AlmaLinux, and is not even in the base repositories:dnf install gdiskanswersNo match for argument: gdisk, and a search acrossbaseos,appstream,crbandextrasreturns nothing. The package lives in EPEL, a third-party repository.partedandfdiskare there by default: prefer them if you cannot add a repository.
To delete a partition with parted, give its number:
sudo parted /dev/sda rm 3Next: format
A partition just created is an empty container. To store data in it, you must format it with a file system (mkfs.ext4, mkfs.xfs...). The choice of file system and the formatting commands are detailed in the dedicated guides, so as not to duplicate them here.
Put it into practice
Handling parted on a disk that has nothing to lose changes everything: you dare, you make mistakes, you start again. The lab has you put a GPT table on the spare disk, carve two partitions (512 MiB and 1 GiB) with parted, then force the kernel to reread the table to validate the layout.
Key points
- A disk needs a partition table before any partition: GPT by default, MBR only for old hardware.
partedcreates the table (mklabel) and the partitions (mkpart) in MBR as in GPT; 1 MiB alignment is automatic.parted printandlsblkcheck the result; an empty File system column flags a partition that is not formatted.mklabelerases the table: always confirm the right disk first.- For flexibility in production, prefer one LVM partition to a frozen layout.
- A partition is only usable once formatted then mounted.
Knowledge check
Check that the essentials of this guide are acquired. The questions only cover what has just been explained here.
Knowledge check
Check what you have learned with this interactive quiz
How it works
- The timer starts when you click Start
- Multiple choice, true/false and short answer questions
- You can move between questions
- Detailed results are shown at the end
Starts the quiz and the timer
Review
(0/0)Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: Choose a file system on Linux
A new full quiz with random questions
Work again only on the questions you missed