How to Partition Linux

How to Partition Linux Partitioning a Linux system is a foundational skill for anyone managing servers, workstations, or embedded devices. It involves dividing a physical storage device—such as a hard drive or SSD—into logically separate sections, each acting as an independent storage unit. This process is critical for organizing data, improving system performance, enhancing security, and ensuring

Nov 10, 2025 - 11:20
Nov 10, 2025 - 11:20
 0

How to Partition Linux

Partitioning a Linux system is a foundational skill for anyone managing servers, workstations, or embedded devices. It involves dividing a physical storage devicesuch as a hard drive or SSDinto logically separate sections, each acting as an independent storage unit. This process is critical for organizing data, improving system performance, enhancing security, and ensuring system stability. Whether you're installing Linux for the first time or reconfiguring an existing installation, understanding how to partition Linux correctly can prevent data loss, optimize disk usage, and simplify system maintenance.

Unlike Windows, which often relies on a single C: drive for both the operating system and user files, Linux embraces a modular approach. Each partition serves a specific purposeboot files, system binaries, user data, temporary files, and swap spaceeach isolated for better control and resilience. Proper partitioning allows you to upgrade or reinstall the OS without affecting personal files, limits the impact of disk full errors, and enables advanced features like encryption, LVM (Logical Volume Management), and RAID configurations.

This guide provides a comprehensive, step-by-step walkthrough of Linux partitioningfrom the theory behind it to real-world implementation. Youll learn how to choose the right partitioning scheme, use industry-standard tools, follow best practices, and troubleshoot common issues. By the end, youll be equipped to confidently partition any Linux system, whether on bare metal or in a virtual environment.

Step-by-Step Guide

Understand Your Storage Goals

Before you begin partitioning, evaluate your systems purpose. Are you setting up a desktop, a web server, a database host, or a development machine? Each use case demands a different partitioning strategy.

For desktop users, a simple scheme with root (/), home (/home), and swap is often sufficient. Server administrators may require additional partitions like /var, /tmp, and /opt to isolate logs, temporary files, and third-party applications. High-availability systems may use LVM or RAID for scalability and redundancy.

Consider your disk size. A 120GB SSD might only need three partitions, while a 4TB NAS drive may benefit from a dozen. Always leave some unallocated space for future expansion or emergency recovery.

Choose a Partitioning Scheme

Linux supports two primary partitioning schemes: MBR (Master Boot Record) and GPT (GUID Partition Table).

  • MBR is legacy, compatible with older BIOS systems, and supports up to four primary partitions (or three primary and one extended with logical partitions). Its limited to 2TB per disk.
  • GPT is modern, required for UEFI boot systems, supports up to 128 partitions, and can handle disks larger than 2TB. It includes redundancy by storing partition table copies at both ends of the disk.

For any new installation, especially on modern hardware (post-2013), use GPT. MBR should only be considered if youre working with legacy systems or embedded devices with strict firmware limitations.

Select a Partitioning Tool

Linux offers several command-line and graphical tools for partitioning. The most widely used are:

  • fdisk Classic, text-based, reliable for MBR and basic GPT tasks.
  • gdisk GPT-specific version of fdisk. Recommended for modern systems.
  • cfdisk Curses-based interface; more user-friendly than fdisk.
  • parted Powerful command-line tool supporting both MBR and GPT, scripting-friendly.
  • GParted Graphical tool ideal for beginners; available in live USB environments.

For this guide, well use gdisk for GPT and fdisk for MBR, as they are pre-installed on most distributions and provide the most control.

Boot from a Live Environment (If Needed)

If youre partitioning a drive that contains your current operating system, you cannot modify it while its mounted. You must boot from a live USB or installation media.

Download a Linux live ISO (Ubuntu, Fedora, or SystemRescue are excellent choices), create a bootable USB using Etcher or dd, and reboot your machine. Select Try Linux or Live Mode to access a full desktop environment without touching your hard drive.

Once booted, open a terminal. Youll need root privileges to manage partitions. Use sudo su or prepend commands with sudo.

Identify Your Disk

Before making changes, identify the correct disk. Use:

lsblk

This lists all block devices. Look for your target disktypically /dev/sda (SATA), /dev/nvme0n1 (NVMe SSD), or /dev/vda (virtual machine). Note the size and existing partitions.

Example output:

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT

nvme0n1 259:0 0 512G 0 disk

??nvme0n1p1 259:1 0 512M 0 part /boot/efi

??nvme0n1p2 259:2 0 32G 0 part /

??nvme0n1p3 259:3 0 479G 0 part /home

In this case, /dev/nvme0n1 is the target. Be absolutely certainaccidentally partitioning the wrong disk can erase critical data.

Backup Existing Data

Partitioning can lead to data loss if done incorrectly. Always backup important files before proceeding. Use rsync, tar, or copy files to an external drive:

rsync -av /home/user/Documents/ /media/external/backup/

If the system is already installed and youre repartitioning, consider cloning the entire disk using dd or Clonezilla as a safety net.

Partition the Disk Using gdisk (GPT)

Run the following command, replacing /dev/nvme0n1 with your target disk:

gdisk /dev/nvme0n1

Youll see a prompt like:

GPT fdisk (gdisk) version 1.0.9

Partition table scan:

MBR: MBR only

BSD: not present

APM: not present

GPT: not present ***

Found invalid GPT and valid MBR; converting MBR to GPT format. ***

Command (? for help):

Type ? to see all commands. Heres the step-by-step workflow:

  1. n Create a new partition.
  2. Enter partition number (default: 1).
  3. First sector (default: 2048) Press Enter to accept.
  4. Last sector Specify size. Use +1G for 1GB, +50G for 50GB, or + to use remaining space.
  5. Type ef00 for EFI System Partition (ESP), 8200 for Linux swap, 8300 for Linux filesystem.

Common partition types:

  • ef00 EFI System Partition (required for UEFI boot)
  • 8200 Linux swap
  • 8300 Linux filesystem (root, home, var, etc.)
  • 8e00 Linux LVM (if using Logical Volume Management)

Example: Creating a minimal GPT layout for a desktop:

  1. Create EFI partition: n ? Enter ? Enter ? +1G ? ef00
  2. Create root partition: n ? Enter ? Enter ? +30G ? 8300
  3. Create home partition: n ? Enter ? Enter ? +100G ? 8300
  4. Create swap: n ? Enter ? Enter ? +8G ? 8200
  5. Remaining space: n ? Enter ? Enter ? Enter ? 8300 (for /opt or /var)

After creating all partitions, type p to print the partition table and verify sizes and types.

When satisfied, type w to write changes to disk. Confirm with Y.

Partitioning with fdisk (MBR)

For older systems or MBR disks, use fdisk:

fdisk /dev/sda

Commands are similar:

  • n New partition
  • p Primary (1-4), or e for extended
  • t Change partition type (e.g., 82 for swap)
  • p Print table
  • w Write and exit

MBR limits you to four primary partitions. If you need more, create one extended partition and then logical partitions inside it.

Format the Partitions

After partitioning, each partition must be formatted with a filesystem. Linux supports ext4, XFS, Btrfs, ZFS, and others.

For most users, ext4 is the best choice: stable, fast, and widely supported.

Format each partition using mkfs:

mkfs.ext4 /dev/nvme0n1p2   

root

mkfs.ext4 /dev/nvme0n1p3

home

mkswap /dev/nvme0n1p4

swap

mkfs.fat -F32 /dev/nvme0n1p1

EFI

For swap, enable it after formatting:

swapon /dev/nvme0n1p4

Verify swap is active:

swapon --show

Mount the Partitions

Before installing the OS, mount the partitions to temporary directories:

mount /dev/nvme0n1p2 /mnt

mkdir /mnt/home

mount /dev/nvme0n1p3 /mnt/home

mkdir /mnt/boot/efi

mount /dev/nvme0n1p1 /mnt/boot/efi

These mounts are temporary and used during OS installation. The installer will write the correct entries to /etc/fstab later.

Install the Operating System

Now proceed with your Linux installer (Ubuntu, Fedora, Arch, etc.). When prompted for partitioning, choose Manual or Something Else.

Assign each partition:

  • /dev/nvme0n1p1 ? /boot/efi (EFI System Partition)
  • /dev/nvme0n1p2 ? / (root)
  • /dev/nvme0n1p3 ? /home
  • /dev/nvme0n1p4 ? swap

Ensure the bootloader is installed to the correct disk (e.g., /dev/nvme0n1, not /dev/nvme0n1p1).

Verify the Installation

After installation, reboot into your new system. Open a terminal and run:

lsblk -f

You should see your partitions with correct filesystems and mount points.

Check swap:

free -h

Check disk usage:

df -h

Verify /etc/fstab contains correct UUIDs:

cat /etc/fstab

Each entry should look like:

UUID=1234-5678 / ext4 defaults 0 1

UUID=abcd-efgh /home ext4 defaults 0 2

UUID=ijkl-mnop none swap sw 0 0

Use blkid to confirm UUIDs match.

Best Practices

Use UUIDs, Not Device Names, in /etc/fstab

Device names like /dev/sda1 can change between bootsespecially when adding or removing drives. UUIDs (Universally Unique Identifiers) are permanent and assigned by the filesystem.

Always reference partitions by UUID in /etc/fstab. To find a partitions UUID:

blkid

Replace /dev/sdXn entries in fstab with UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.

Separate /home from Root

One of the most important Linux partitioning practices is isolating /home. This directory stores all user datadocuments, downloads, configurations, and application data.

By separating /home, you can reinstall or upgrade the OS without touching personal files. If the root partition becomes corrupted, your data remains intact.

Allocate at least 100GB to /home on desktop systems. For servers, consider larger sizes based on expected user data.

Use Swap Wisely

Swap space acts as virtual memory when RAM is full. Traditionally, swap was sized at 1.5x to 2x RAM. Modern systems with 8GB+ RAM often need less.

Recommended swap sizes:

  • Under 4GB RAM ? 2x RAM
  • 48GB RAM ? Equal to RAM
  • 816GB RAM ? 0.5x RAM
  • 16GB+ RAM ? 48GB (or even none if using hibernation)

If you plan to use hibernation (suspend to disk), swap must be at least as large as your RAM.

Consider using a swap file instead of a partition. Its easier to resize and doesnt require repartitioning. Modern Linux kernels handle swap files efficiently.

Isolate /var and /tmp for Servers

On servers, /var holds logs, databases, mail queues, and caches. These can grow rapidly and fill the root partition.

Allocate 2050GB to /var depending on usage. For high-traffic web servers or databases, consider 100GB+.

/tmp is used for temporary files. Set it to 510GB and mount with noexec,nosuid to enhance security:

/dev/nvme0n1p5 /tmp ext4 defaults,noexec,nosuid,nodev 0 2

Enable LVM for Flexibility

Logical Volume Management (LVM) allows dynamic resizing of partitions without repartitioning. Its ideal for servers and systems with evolving storage needs.

Instead of creating fixed-size partitions, create a single large partition (type 8e00) and use it as a Physical Volume (PV). Then create Volume Groups (VG) and Logical Volumes (LV) for /, /home, /var, etc.

Benefits:

  • Resize LVs online with lvextend and resize2fs
  • Add new disks to VG without downtime
  • Create snapshots for backups

Use LVM if you anticipate future storage changes. For desktops, simple partitioning is often sufficient.

Encrypt Sensitive Partitions

For privacy and security, encrypt /home or the entire root filesystem using LUKS (Linux Unified Key Setup).

During installation, select Encrypt the new Linux installation or manually set up LUKS with:

cryptsetup luksFormat /dev/nvme0n1p2

cryptsetup open /dev/nvme0n1p2 cryptroot

mkfs.ext4 /dev/mapper/cryptroot

mount /dev/mapper/cryptroot /mnt

LUKS adds minimal overhead and is supported by all major distributions.

Leave Unallocated Space

Never fill a disk to 100%. Leave 510% unallocated for:

  • Future partition expansion
  • Rescue or recovery tools
  • SSD wear leveling and performance

SSDs perform better with free space for garbage collection. Ext4 and XFS also reserve 5% for root to prevent system lockups when the disk is full.

Align Partitions Correctly

Modern tools like gdisk and parted auto-align partitions to 1MB boundaries for optimal SSD performance. Avoid using old tools like fdisk without alignment flags.

Always check alignment with:

parted /dev/nvme0n1 unit MiB print

Start and end sectors should be multiples of 2048 (1MiB).

Tools and Resources

Command-Line Tools

  • gdisk Best for GPT partitioning. Supports advanced features like backup tables and GUIDs.
  • fdisk Reliable for MBR and basic GPT. Available on all Linux systems.
  • parted Scriptable, supports resize and move operations. Use with caution on live systems.
  • lsblk Lists block devices with filesystems and mount points. Essential for verification.
  • blkid Displays UUIDs and filesystem types. Critical for fstab configuration.
  • df Shows disk usage by mount point.
  • du Estimates file space usage. Useful for planning /home or /var sizes.
  • mkfs.ext4, mkfs.xfs, mkswap Filesystem creation tools.
  • cryptsetup For LUKS encryption setup.
  • lvcreate, lvextend, vgdisplay LVM management tools.

Graphical Tools

  • GParted The most popular GUI partition editor. Available in live CDs. Drag-and-drop resizing, formatting, and copying.
  • KDE Partition Manager Feature-rich, supports advanced LVM and RAID operations.
  • Disks (gnome-disks) Built into GNOME. Good for basic partitioning and SMART monitoring.

Documentation and References

  • Linux Documentation Project (tldp.org) Comprehensive guides on LVM, RAID, and filesystems.
  • Arch Wiki (wiki.archlinux.org) Excellent, community-maintained documentation on partitioning, bootloaders, and encryption.
  • man pages Always consult man gdisk, man mkfs.ext4, or man fstab for detailed options.
  • Ubuntu Server Guide Practical partitioning examples for server deployments.

Live USB Distributions

  • SystemRescue Designed for system recovery. Includes gdisk, parted, fsck, and LVM tools.
  • Ubuntu Live Familiar interface, good for beginners.
  • Fedora Live Cutting-edge tools and kernel support.
  • Clonezilla For disk cloning and imaging before partitioning.

Online Calculators and Templates

Use online partition size calculators to estimate needs:

These tools provide recommendations based on disk size and use case.

Real Examples

Example 1: Desktop Linux Installation (512GB SSD)

Goal: Install Ubuntu 24.04 on a new laptop with 512GB NVMe SSD.

Partition Scheme (GPT):

PartitionSizeTypeMount PointFilesystem
/dev/nvme0n1p11GBEFI System/boot/efifat32
/dev/nvme0n1p250GBLinux/ext4
/dev/nvme0n1p3300GBLinux/homeext4
/dev/nvme0n1p48GBLinux swapswapswap
/dev/nvme0n1p5153GBLinux/optext4

Why this layout?

  • 1GB EFI: Sufficient for UEFI boot files.
  • 50GB root: Enough for OS, apps, and updates (Ubuntu 24.04 uses ~15GB).
  • 300GB home: Ample space for documents, media, and downloads.
  • 8GB swap: Matches 8GB RAM; supports hibernation.
  • 153GB /opt: Reserved for development tools, Docker containers, and VMs.

This setup ensures the system remains responsive, personal data is safe, and future software installations wont interfere with the OS.

Example 2: Web Server (2TB HDD)

Goal: Deploy a LAMP stack (Linux, Apache, MySQL, PHP) on a 2TB hard drive.

Partition Scheme (GPT + LVM):

PartitionSizeTypeMount PointFilesystem
/dev/sda11GBEFI/boot/efifat32
/dev/sda21.9TBLVM PV--

LVM Logical Volumes:

LV NameSizeMount PointFilesystem
lv_root100GB/xfs
lv_var300GB/varxfs
lv_home50GB/homexfs
lv_swap16GBswapswap
lv_backup1.45TB/backupxfs

Why this layout?

  • LVM allows dynamic expansion: if /var fills up, extend lv_var without downtime.
  • XFS is optimized for large files and high throughputideal for logs and databases.
  • 1.45TB /backup: Dedicated space for database dumps, website archives, and configuration backups.
  • 16GB swap: Server has 16GB RAM; swap is for emergency use, not regular operation.

This configuration ensures high availability, scalability, and ease of maintenance.

Example 3: Minimal Embedded System (32GB eMMC)

Goal: Run a lightweight Linux distribution on a Raspberry Pi 4 with 32GB eMMC storage.

Partition Scheme (MBR):

PartitionSizeTypeMount PointFilesystem
/dev/mmcblk0p1256MBFAT32/bootvfat
/dev/mmcblk0p231.75GBLinux/ext4

Why this layout?

  • 256MB boot partition: Required for Raspberry Pi firmware and kernel.
  • Single root partition: No need for /home or swap; system runs headless.
  • No swap: RAM is limited (4GB); use zram instead (compressed RAM swap).
  • Optimized for low write cycles: ext4 with noatime mount option.

Use noatime in /etc/fstab to reduce writes:

UUID=1234-5678 / ext4 defaults,noatime,errors=remount-ro 0 1

FAQs

Can I partition a disk without losing data?

Yes, but with caution. Tools like GParted can resize partitions without data lossprovided theres enough free space. Always backup first. Never resize a partition thats mounted and in use.

Do I need a separate /boot partition?

On UEFI systems, you need a separate EFI System Partition (ESP) for boot files. A traditional /boot partition (ext4) is optional unless youre using LVM, RAID, or full-disk encryptionthen its required so the bootloader can access kernel images.

Whats the difference between a partition and a filesystem?

A partition is a section of the physical disk. A filesystem (like ext4 or XFS) is the structure that organizes files within that partition. You must format a partition with a filesystem before you can store files on it.

Can I change partition sizes after installation?

Yes, but its risky. Use GParted from a live USB. For LVM, use lvextend and resize2fs/xfs_growfs. Always backup first. Never shrink a filesystem without unmounting and checking for errors.

Is swap still necessary with 16GB+ of RAM?

Not strictly necessary for desktop use, but recommended for servers and systems using hibernation. Swap also helps with memory management under heavy load. A small 48GB swap is harmless and provides a safety net.

Why does my disk show less space than advertised?

Manufacturers use decimal (1GB = 1,000,000,000 bytes), while Linux uses binary (1GiB = 1,073,741,824 bytes). Also, filesystem metadata, reserved blocks, and partition tables consume space. A 512GB SSD may show ~475GB usable.

How do I know if my partition is aligned correctly?

Run parted /dev/sdX unit MiB print. The Start column should show multiples of 1 (e.g., 1MiB, 513MiB). Misalignment can reduce SSD performance by 1030%.

Can I use Btrfs or ZFS for root?

Yes. Btrfs offers snapshots and built-in RAID. ZFS provides advanced data integrity. Both require more RAM and are not default in all distributions. Use them only if you need their advanced features.

What if I mess up the partition table?

If you accidentally delete partitions, stop immediately. Use testdisk to recover lost partitions. Never write new data to the disk. testdisk can scan for old partition signatures and restore them.

Conclusion

Partitioning Linux is more than a technical taskits a strategic decision that impacts system performance, security, and long-term maintainability. Whether youre setting up a personal laptop or a production server, taking the time to plan your partition layout correctly pays dividends in stability and ease of management.

This guide has walked you through the entire process: from understanding the purpose of each partition, selecting the right tools, following best practices like using UUIDs and LVM, to applying real-world examples tailored to desktops, servers, and embedded systems. You now know how to create a robust, scalable, and secure partitioning scheme using industry-standard tools like gdisk, fdisk, and parted.

Remember: always backup your data before partitioning, use GPT for modern systems, separate /home from root, and prefer LVM for dynamic environments. Avoid one-size-fits-all approachesyour partitioning strategy should reflect your use case, hardware, and future needs.

Linuxs modular design gives you unparalleled control over your system. Partitioning is one of the most powerful ways to leverage that control. With the knowledge gained here, youre equipped to make informed decisions that will keep your systems running smoothly for years to come.