Skip to main content
Linux lets you divide a physical disk into multiple partitions, each with its own filesystem. For example, on a 2 TB SSD you might allocate 1 TB for Windows (NTFS) and 1 TB for Linux (ext4). Partitioning keeps filesystems separate and lets each OS manage its space independently.

Why Partition a Disk?

  • Separate operating systems (e.g., Windows vs. Linux)
  • Isolate data, swap, and boot partitions
  • Use different partition table formats: MBR (DOS) vs. GPT (modern systems)
Leaving 1 MiB unallocated at the start of the disk is a best practice. Many bootloaders require this alignment for optimal performance.

1. Viewing Existing Partitions

Use lsblk to list block devices and their partitions:
Only entries with TYPE part are actual partitions:

2. Inspecting the Partition Table with fdisk

To view the partition table on /dev/sda, run:
Sample output:
  • Disklabel type: dos indicates an MBR partition table.
  • Start and End are measured in 512-byte sectors.

3. Creating and Modifying Partitions with cfdisk

cfdisk offers an ncurses interface for partitioning. It’s especially helpful on servers without a GUI.

Steps to Partition /dev/sdb

  1. Attach the disk (e.g., sdb) and launch:
  2. Select a label:
    • GPT for modern UEFI systems.
    • DOS for legacy MBR.
  3. Create partitions:
    • Navigate to Free SpaceNew → enter 8GEnter.
    • Repeat in remaining free space with 2G.
  4. Resize or split (optional):
    • Highlight a partition → Resize → enter new size (e.g., 4G).
    • Use freed space to create another partition.
The image shows a terminal window displaying disk partition information for /dev/sdb, including details about partitions, free space, and options for managing them.

3.1 Setting a Partition Type

The default type is “Linux filesystem.” To mark /dev/sdb3 as swap:
  • Highlight sdb3Type → select Linux swapEnter.
The image shows a terminal window with a menu for selecting a partition type, highlighting "Linux swap" among various options like EFI System and Microsoft reserved.
You can also choose types like EFI System for UEFI boot partitions or Microsoft reserved for Windows.
The image shows a terminal window displaying a disk partitioning tool on a CentOS system, listing partitions on the disk /dev/sdb with details like size and type.
When you Write changes in cfdisk, all partition modifications become permanent. Double-check before confirming.

3.2 Writing and Quitting

  1. Select Write, type yes, and press Enter.
  2. Select Quit to exit cfdisk.

4. Verifying the New Partitions

Back in the shell, confirm with lsblk:
Now /dev/sdb has three partitions: two 4 GiB data partitions and one 2 GiB swap.

Summary of Common Commands

Watch Video