(Last Updated On: April 19, 2019)

This guide will show you how to extend or resize an ext2/3/4 and XFS File System without LVM at runtime. This could be a root partition configured with ext2/3/4 or XFS filesystem but without any LVM configured. In our previous tutorial, we looked at How to extend root filesystem using LVM on Linux.

resize ext2 / ext3 / ext4 / XFS root partition at runtime

Step 1: Check your current root disk capacity

For this demonstration, I have a CentOS 7 VM with below partition scheme.

$ lsblk 
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
vda 253:0 0 10G 0 disk
└─vda1 253:1 0 10G 0 part /

As seen from the output, the root filesystem is on /dev/vda1 partition without LVM.

Step 2: Extend your OS root disk

I will extend my root block device to 30GB. I use KVM virtualization technology, so this guide works for me:

How to extend/increase KVM Virtual Machine (VM) disk size

$ sudo virsh domblklist centos7 
 Target   Source
-------------------------------------------------
 vda      /var/lib/libvirthttps://computingforgeeks.com/images/centos7.qcow2
 sda      -

$ sudo fdisk -l /var/lib/libvirthttps://computingforgeeks.com/images/centos7.qcow2
Disk /var/lib/libvirthttps://computingforgeeks.com/images/centos7.qcow2: 10 GiB, 10739318784 bytes, 20975232 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

$ sudo qemu-img resize /var/lib/libvirthttps://computingforgeeks.com/images/centos7.qcow2 +20G
Image resized.

If you’re on a different Virtualization platform, refer to its documentation for how to extend OS virtual disk.

Step 3: Grow VM partition

Start your VM and ssh as a user with sudo privileges. The first thing to do is to confirm the new disk size.

$ lsblk 
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
vda 253:0 0 30G 0 disk
└─vda1 253:1 0 10G 0 part /

We can see the disk has grown by 20GB, from 10GB to 30GB. The next action is to expand the partition (Partition 1) in our example, to the maximum size the disk provides.

Install cloud utils

For those new to growpart, it is a Linux command line tool used to extend a partition in a partition table to fill available space. This command is provided by cloud utils package.

On Ubuntu / Debian system, run

sudo apt -y install cloud-guest-utils

For CentOS server, run

sudo yum -y install cloud-utils-growpart

Help page can be viewed by passing -h argument

# growpart -h
growpart disk partition
   rewrite partition table so that partition takes up all the space it can
   options:
    -h | --help       print Usage and exit
         --fudge F    if part could be resized, but change would be
                      less than 'F' bytes, do not resize (default: 1048576)
    -N | --dry-run    only report what would be done, show new 'sfdisk -d'
    -v | --verbose    increase verbosity / debug
    -u | --update  R update the the kernel partition table info after growing
                      this requires kernel support and 'partx --update'
                      R is one of:
                       - 'auto'  : [default] update partition if possible
                       - 'force' : try despite sanity checks (fail on failure)
                       - 'off'   : do not attempt
                       - 'on'    : fail if sanity checks indicate no support

   Example:
    - growpart /dev/sda 1
      Resize partition 1 on /dev/sd

Now use growpart to extend your partition.

$ sudo growpart /dev/vda 1
CHANGED: partition=1 start=2048 old: size=20969472 end=20971520 new: size=62912479,end=62914527

This will resize partition 1 on /dev/vda.

Validate the change.

$ lsblk 
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
vda 253:0 0 30G 0 disk
└─vda1 253:1 0 30G 0 part /

Step 4: Resize ‘/’ partition to fill all space

The last step is to resize the file system to grow all the way to fill added space

For ext4 file system, use resize2fs

$ sudo resize2fs /dev/vda1
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 4
The filesystem on /dev/vda1 is now 7864059 blocks long.

If your filesystem is XFS, it can be grown while mounted using the xfs_growfs command:

sudo xfs_growfs /

Confirm new size using df -h

$ df -hT | grep /dev/vda
/dev/vda1 ext4 30G 1.2G 27G 5% /

Congratulations!, you have successfully resized an ext2/3/4 or XFS root partition on Linux without LVM. See related articles below.

How to extend EBS boot disk on AWS without an instance reboot

How to extend root filesystem using LVM on Linux

How to extend/increase KVM Virtual Machine (VM) disk size

Working with qemu-img in Linux