- growpart command :
- How to Install cloud utils package on the system
- How to extend root filesystem using LVM on Linux
- 4: Update changes on the filesystem (If you didn’t use -r option in step 3)
In this tutorial, we will teach you how to resize your hard disk partitions in Linux by introducing a very useful tool. You can easily resize all partitions with this utility. Whether this is a root partition or any other partition. No need to enter a rescue mode or reboot. this will also cover both ext4 and XFS filesystem root partition extending. This tool is called growpart and we are going to do a lot of things in this tutorial using this tool.
growpart command : #
How to Install cloud utils package on the system #
On Ubuntu / Debian system, run the commands below to install growpart tool.
For CentOS server, run:
Help page can be viewed by passing -h argument
How to extend root filesystem using LVM on Linux #
- Create an LVM physical volume, volume group, and logical volume.
- Create an XFS and ext4 filesystem on the logical volumes
- Extend LVM logical volumes ( root and non-root filesystem)
1. Check the condition of the disk and its structure #
2: Extend your desired disk size (root partition or other) #
If you did not reboot your server after resizing the partition, rescan your SCSI devices as such.
First, check the name(s) of your SCSI devices.
Then rescan the scsi bus. Below you can replace the ‘0:0:0:0’ with the actual scsi bus name found with the previous command. Each colon is prefixed with a slash, which is what makes it look weird.
Now use growpart to extend your partition. In this example, we’re extending partition 2 in disk /dev/sda. (Replace 2 and /dev/sda with your correct values.)
Confirm if the change was successful.
Step 3: Resize root logical volume to occupy all space #
Resize physical volume. (command:
This extends the logical volume to use all available capacity in the volume group. With the + sign the value is added to the actual size of the logical volume.
Command options used:
- -l – extend or set the logical volume size in units of logical extents
- -r – Resize underlying filesystem together with the logical volume
Where size suffix are:
- M for megabytes
- G for gigabytes
- T for terabytes
- P for petabytes
- E for exabytes
Without the + sign the value is taken as an absolute one.
So we have now:
and still 30G Free:
4: Update changes on the filesystem (If you didn’t use -r option in step 3) #
Your root filesystem will still show the old size.
Let’s make the filesystem report the actual size, including extended.
For ext4 filesystem
For xfs filesystem