This guide will walk you through the process of resizing an ext2/3/4 or XFS file system without using LVM (Logical Volume Manager) during runtime. This method works even for a root partition.

Step 1: Check Your Current Disk Size

To begin, let's check the size of the root partition. In this example, we'll use a CentOS 7 virtual machine (VM) with the following partition layout:

$ 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, the root partition is /dev/vda1, which does not use LVM.

Step 2: Increase the Root Disk Size

To expand the disk, you first need to increase the size of the root disk. In this case, we are using KVM virtualization technology and will expand the disk to 30GB.

Find the virtual disk location using:

$ sudo virsh domblklist centos7
Target Source
-------------------------------------------------
vda /var/lib/libvirt/images/centos7.qcow2

Next, extend the disk size:

$ sudo qemu-img resize /var/lib/libvirt/images/centos7.qcow2 +20G

If you are using a different virtualization platform, follow its documentation to increase the virtual disk size.

Step 3: Expand the VM Partition

After increasing the disk size, reboot your VM and log in with sudo privileges. Then, 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 /

The disk has grown to 30GB, but the root partition (/dev/vda1) remains 10GB. We now need to extend this partition.

Install growpart Utility

growpart is a command-line tool used to extend a partition. Install it by running the following:

On Ubuntu/Debian:

sudo apt -y install cloud-guest-utils gdisk

On CentOS/RHEL/Fedora:

sudo yum -y install cloud-utils-growpart gdisk

Extend the partition by running:

$ sudo growpart /dev/vda 1

You should see an output similar to this:

CHANGED: partition=1 start=2048 old: size=20969472 end=20971520 new: size=62912479,end=62914527

This command resizes the partition to fill the expanded disk space.

Verify 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 the File System

Now that the partition has been extended, the final step is to resize the file system to fill the newly added space.

For ext4 file systems, use resize2fs:

$ sudo resize2fs /dev/vda1

You'll see an output confirming the file system has been resized.

For XFS file systems, use the xfs_growfs command:

$ sudo xfs_growfs /

Verify the new partition size with:

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

Conclusion

You’ve successfully resized your ext2/3/4 or XFS root partition without using LVM! This method works for both root and non-root partitions and allows you to expand your disk without interrupting the system.

Take full control of your hosting environment today by choosing a dedicated server that suits your needs. Explore our dedicated server plans and elevate your business with Ucartz’s top-tier performance solutions.

Was this answer helpful? 0 Users Found This Useful (0 Votes)