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, 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 the commands below to install growpart tool.
For CentOS server, run:
Help page can be viewed by passing -h argument
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.)
CHANGED: partition=2 start=2099200 old: size=39843840 end=41943040 new: size=102758367 end=104857567
Confirm if the change was successful.
Resize physical volume. (command: pvresize)
# pvresize /dev/sda2
Physical volume “/dev/sda2” changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized
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:
Where size suffix are:
Without the + sign the value is taken as an absolute one.
So we have now:
and still 30G Free:
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
Powered by BetterDocs
207 Regent Street ,
London W1B 3HH – UK
+44 203 239 1536
©2021 DADE2. All rights reserved