Linux

Resizing Linux File Systems: A Step-by-Step Guide

This guide explains how to safely resize file systems in Linux using utilities like parted, resize2fs, and xfs_growfs. You'll learn how to both expand and shrink partitions.

Updated at February 16, 2026
15-30 minutes
Medium
FixPedia Team
Применимо к:Ubuntu 22.04+Debian 11+CentOS 8+Fedora 35+Linux kernel 5.x+

Introduction / Why This Is Needed

Resizing a filesystem is an operation often required when managing disk space. You may need to expand a partition to accommodate new data or shrink it to free up space for other purposes. This guide covers the main scenarios for popular filesystems (ext4, XFS, Btrfs) and partition types (standard, LVM). After completing it, you will be able to safely resize partitions without data loss.

Requirements / Preparation

Before starting, perform the following actions:

  1. Administrator privileges: all commands require sudo.
  2. Data backup: make a full backup of important files to an external drive or cloud storage.
  3. Determine the current structure:
    lsblk -f
    sudo fdisk -l
    
    Pay attention to:
    • Partition type (GPT/MBR)
    • Filesystem (ext4, xfs, btrfs...)
    • Mount point
  4. Free up space (if shrinking): delete unnecessary files, empty the trash, run sudo apt clean (for Debian/Ubuntu).
  5. Check filesystem integrity:
    sudo fsck -f /dev/sdXN   # for ext4
    sudo xfs_repair /dev/sdXN # for XFS (must be unmounted!)
    

Step 1: Resize the Partition

For Partitions on SSD/HDD (GPT or MBR)

Use parted (recommended for GPT) or fdisk (for MBR). Important: the partition's starting sector must remain unchanged, otherwise data will be lost.

Example for ext4 (expansion)

# Start parted
sudo parted /dev/sda

# Find the partition number (e.g., 2)
print

# Delete the partition (BUT do not format!)
rm 2

# Create a new partition with the same start but a larger end
mkpart primary ext4 512MiB 100%   # replace 512MiB with the original start (see print)

# Exit
quit

For LVM (Logical Volume Manager)

If the partition uses LVM, the process is simpler:

# Shrink the logical volume (first the filesystem!)
sudo lvreduce -L -10G /dev/mapper/vg0-lv_root   # reduce by 10GB

# Extend the logical volume
sudo lvextend -L +10G /dev/mapper/vg0-lv_root

⚠️ Attention: When shrinking LVM, first reduce the filesystem, then the volume. When extending—first the volume, then the filesystem.

Step 2: Resize the Filesystem

Now, after resizing the partition (or LVM volume), you need to adjust the filesystem to fit.

For ext4

# If the partition was expanded
sudo resize2fs /dev/sdXN

# If the partition was shrunk (only after reducing the partition!)
sudo resize2fs /dev/sdXN

For XFS

XFS supports only growing and only when the filesystem is mounted:

# Mount the partition if not mounted
sudo mount /dev/sdXN /mnt

# Grow the filesystem to the partition's maximum size
sudo xfs_growfs /mnt

Shrinking XFS is impossible without recreating the partition and restoring from a backup.

For Btrfs

# Grow (online)
sudo btrfs filesystem resize max /mountpoint

# Shrink (only on an unmounted filesystem)
sudo btrfs filesystem resize 50G /dev/sdXN   # to 50GB

Step 3: Verify the Result

After all operations, ensure the changes were applied correctly:

# Show partition sizes
lsblk

# Show sizes of mounted filesystems
df -h

# For ext4, you can check the superblock
sudo dumpe2fs -h /dev/sdXN | grep -i "block count"

If df -h shows the expected size—the operation was successful. If the size did not change, you may have forgotten to resize the filesystem after changing the partition.

Potential Issues

Error: "Filesystem is mounted" when trying to shrink ext4

Solution: Unmount the partition: sudo umount /mountpoint. If it's the root partition, boot from a LiveCD.

Error: "No space left on device" when shrinking a partition

Solution: You did not free enough space inside the filesystem. Delete more files or use sudo resize2fs /dev/sdXN 20G to forcefully set a smaller size (risk of data loss!).

Error: "Bad primary partition" after using parted

Solution: You may have changed the starting sector. Recover the partition using testdisk or restore from a partition table backup.

XFS does not grow after xfs_growfs

Solution: Ensure the partition was actually extended (check with lsblk). If the partition is on LVM, extend the volume first: lvextend.

System fails to boot after resizing

Solution: Check /etc/fstab—it may reference an old UUID. Update the UUID using blkid and edit fstab from a LiveCD.

F.A.Q.

Can the root partition be resized without booting from a Live CD?
What to do if the file system doesn't mount after resizing?
How to resize an XFS file system?
Is it safe to shrink a file system with data?

Hints

Preparation and analysis of current structure
Resizing the partition (parted/fdisk)
Resizing the file system
Verifying the result
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community