Expnanding HD by 100GB

I recently expanded my HD by +200GB instead of +100GB by accident. I booted up my machine, and went to use parted to expand by 100GB with resize, but it failed:
(parted) resize 2 100GB Error: The resize command has been removed in parted 3.0
I see there is growpart, but I don’t want to use the full 200GB, only an extra 100GB. How can I do this?
fdisk -l:

Device     Boot   Start       End   Sectors  Size Id Type
/dev/sda1  *       2048   2099199   2097152    1G 83 Linux
/dev/sda2       2099200 419430399 417331200  199G 8e Linux LVM

Using, eg:

growpart -h

an example is given of:

    - growpart --free-percent=10 /dev/sda 1
      Resize partition 1 on /dev/sda so that 10% of the disk is unallocated

if you have 200GB free and want to use 100GB, then your free percentage would be 50. So:

growpart --free-percent=50 /dev/sda 2

The lsblk shows data in useful way too.

You have two partitions and the second is a LVM PV. There are more than one way to proceed.

  • One could add a third partition, initialize it as PV, add to the VG, and expand LV(s) as necessary
  • One could remove partition 2 and create it again (same start and type, correct size). Then pvresize and expand LV(s)
  • One could use that growpart. Then expand LV(s)
  • One could add a third partition, initialize filesystem to it, and mount it where needed
  • One could “shrink the HDD” by 100GB and then growpart?

What is growpart?

$ dnf provides *bin/growpart
cloud-utils-growpart-0.33-1.el9.x86_64 : Script for growing a partition
Repo        : appstream
Matched from:
Other       : *bin/growpart

$ dnf info cloud-utils-growpart | grep -A5 Description
Description  : This package provides the growpart script for growing a partition. It is
             : primarily used in cloud images in conjunction with the dracut-modules-growroot
             : package to grow the root partition on first boot.

Apparently a script that calls sfdisk or sgdisk (and pvresize) to manipulate partition table (and PV).

        if [ -n "${free_percent}" ]; then
                free_percent_sectors=$((sector_num/100*free_percent))
                ...

If the disk is now 400GB, then free_percent should be 25 in order to leave 100GB free?

I get this error message:
NOCHANGE: partition 2 could not be grown while leaving 50% (419430400 sectors) free on device

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.