Skip to content
Français
Account: not signed in, sync available My learning
Select theme
Français

Manage partitions on Linux

By updated

Improve this page

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 print and lsblk
  • Know where fdisk and gdisk remain relevant

Prerequisites

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 /var do not stop the root system from working if /var is on its own partition.
  • Security: a dedicated partition can receive restrictive mount options in /etc/fstab (noexec, nosuid, nodev), useful on /tmp or /home.
  • Targeted backup: back up or restore /home without 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.

FeatureMBR (msdos)GPT
Primary partitions4 maximum128 (common usage)
Disk size handled2 TiBfar beyond
FirmwareLegacy BIOSUEFI (and BIOS)
Table redundancynoyes (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:

Terminal window
sudo parted -s /dev/sda mklabel gpt

Then 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:

Terminal window
sudo parted -s /dev/sda mkpart data1 ext4 1MiB 3GiB
sudo parted -s /dev/sda mkpart data2 xfs 3GiB 5GiB
sudo 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:

Terminal window
sudo parted /dev/sda print
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 10.7GB
Partition 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 lvm

The File system column is empty: the partitions exist but are not formatted yet. lsblk confirms the tree with rounded sizes:

Terminal window
lsblk /dev/sda
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 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 part

fdisk 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, n creates a partition, d deletes one, p prints, w writes the changes. Handy for step-by-step exploration. sudo fdisk -l lists all the tables of the system.
  • gdisk: a fdisk equivalent 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 gdisk answers No match for argument: gdisk, and a search across baseos, appstream, crb and extras returns nothing. The package lives in EPEL, a third-party repository. parted and fdisk are there by default: prefer them if you cannot add a repository.

To delete a partition with parted, give its number:

Terminal window
sudo parted /dev/sda rm 3

Next: 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.
  • parted creates the table (mklabel) and the partitions (mkpart) in MBR as in GPT; 1 MiB alignment is automatic.
  • parted print and lsblk check the result; an empty File system column flags a partition that is not formatted.
  • mklabel erases 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

6 questions
6 min
70% to pass

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

Is this project useful to you?

The guides, courses, quizzes and labs stay free. If you use them regularly, you can contribute to their upkeep and development.

Become a supporting member (new tab) One-time support (new tab) Learn more

Follow the project on LinkedIn