A partition is a separate section of a disk that the operating system treats as its own unit. Partitioning lets you keep the operating system, user data and swap apart, use different file systems or install more than one OS. This guide explains partition tables and types, then shows how to create a disk partition in Linux step by step.

Why partition a disk?
- Separate system files from data, so reinstalling the OS keeps data safe.
- Stop log files or user data from filling the root file system.
- Use different file systems or mount options for different purposes.
- Dual-boot several operating systems.
Partition tables: MBR vs GPT
| Feature | MBR | GPT |
|---|---|---|
| Maximum disk size | 2 TiB (with 512-byte sectors) | Practically unlimited (zettabytes) |
| Number of partitions | 4 primary, or 3 primary + 1 extended | 128 by default |
| Firmware | Legacy BIOS | UEFI (and BIOS with a small boot partition) |
| Redundancy | Single partition table | Backup table at the end of the disk |
GPT is the modern standard. Use it for new systems unless you must support very old hardware.
Primary, extended and logical partitions
On MBR disks, you can have at most four primary partitions. To get more, one of them can be an extended partition, which holds several logical partitions. GPT does not need this workaround.
Partition naming in Linux
- SATA and SAS disks:
/dev/sda, partitions/dev/sda1,/dev/sda2. - NVMe drives:
/dev/nvme0n1, partitions/dev/nvme0n1p1. - Virtual disks: often
/dev/vdaor/dev/xvda.
Step-by-step: create a partition
In this example, /dev/sdb is a new, empty disk. Warning: partitioning the wrong disk destroys data, so check carefully with lsblk.
1. List disks
lsblk
sudo fdisk -l2. Create a GPT partition table and partition with parted
sudo parted /dev/sdb --script mklabel gpt
sudo parted /dev/sdb --script mkpart data xfs 0% 100%Alternatively, use fdisk /dev/sdb interactively: press g for a new GPT table, n for a new partition, accept the defaults and press w to write.
3. Create a file system
sudo mkfs.xfs /dev/sdb1
# or: sudo mkfs.ext4 /dev/sdb14. Mount the partition
sudo mkdir -p /data
sudo mount /dev/sdb1 /data
df -h /data5. Mount it automatically at boot
Find the UUID with blkid /dev/sdb1, then add a line to /etc/fstab:
UUID=your-uuid-here /data xfs defaults,nofail 0 0Run sudo mount -a to test. The nofail option lets the system boot even if this disk is missing.
Common file systems
| File system | Best for |
|---|---|
| ext4 | General purpose; default on many distributions |
| XFS | Large files and servers; default on RHEL-family systems |
| Btrfs | Snapshots, checksums and compression |
| vfat (FAT32) | EFI system partition and USB drives |
Partitions vs LVM
Plain partitions are simple, but resizing them is hard. LVM adds a flexible layer on top, so you can grow volumes online. See how to create an LVM partition.
Related guides
Sources
Running Linux servers in production? Our Linux server hardening & security audit checks configuration, patching, SSH and logging. You can also use our free Linux server hardening checklist, or contact us.

Pingback: What is Swap Partition and how to create it on Linux - Youngster Company
Pingback: What is LVM Partition and how to create it on Linux - Youngster Company