Disk Extend EXT2/3/4 and XFS root partition without LVM
Disk Extend EXT2/3/4 and XFS root partition without LVM
Looking for steps to grow your KVM VM/Container’s partition after extending root OS size or extending ext2/3/4 and XFS root partition without LVM at runtime. Steps to extend root partition without LVM are quite easy and can be followed without going into many technical details. This guide will also help system admins who have increased the KVM Container root OS size from the Host node but inside Container the partition size remains the same. Steps will work on most Debian/Ubuntu and CentOS based systems.
Requirements
- Root access to the System/VM/Container.
- Extended root OS Size (for KVM VM/Containers only)
Procedure
- Log in to the root user of the System/VM/Container after root OS Size is increased.
- Check the partition details of the system using
lsblkandfdisk -lcommands as the image below.

- It can be seen the OS partition size
vdais 160GB in total but thevda1system root/the total size is 80GB currently. More details can be seen usingdf -hthe command.

- To extend the partition we need to install
cloud utilspackage and usegrowpartthecommand to increase the partition. Thegrowpartis a Linux command-line tool used to extend a partition in a partition table to fill available space. Use the following command to installcloud utilspackage.
On Ubuntu / Debian system:
sudo apt -y install cloud-guest-utils gdiskFor CentOS System:
sudo yum -y install cloud-utils-growpart gdisk

- Use
growpartto extend the partitionvda1.
growpart /dev/vda 1

Here/dev/vdais the main OS Partition and1is sub-partition number 1 which means we are extending/dev/vda1partition using the above command. - Now check the partitions details using
lsblkcommand. It should show sub-partition number 1 extended to 160GB.

- Now, check what type of partition your system is using with the help of
df -Thcommand. In our case, our system is using ext4 partition.

- Now, we need to resize
/partition to fill all space in/dev/vda1partition using theresize2fsfor ext partition command as below.
resize2fs /dev/vda1

If your filesystem is XFS, it can be grown while mounted using thexfs_growfscommand as below.
xfs_growfs -d /dev/vda1 - Confirm the new size using
df -h,lsblkandfdisk -lcommands. You can see now vda1 partition is 160GB in total size.

And it’s done, you have now learnt how to extend an ext2/3/4 or XFS root partition on Linux without LVM.
