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.
- Root access to the System/VM/Container.
- Extended root OS Size (for KVM VM/Containers only)
- 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
fdisk -lcommands as the image below.
- It can be seen the OS partition size
vdais 160GB in total but the
/the total size is 80GB currently. More details can be seen using
df -hthe command.
- To extend the partition we need to install
cloud utilspackage and use
growpartthecommand to increase the partition. The
growpartis a Linux command-line tool used to extend a partition in a partition table to fill available space. Use the following command to install
On Ubuntu / Debian system:
sudo apt -y install cloud-guest-utils gdiskFor CentOS System:
sudo yum -y install cloud-utils-growpart gdisk
growpartto extend the partition
growpart /dev/vda 1
/dev/vdais the main OS Partition and
1is 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 the
resize2fsfor ext partition command as below.
If your filesystem is XFS, it can be grown while mounted using the
xfs_growfscommand as below.
xfs_growfs -d /dev/vda1
- Confirm the new size using
fdisk -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.