Enlarging a virtual disk partition

sacarias

Active Member
Oct 2, 2019
64
1
26
Trying to enlarge a partition in an old Centos 7 VM guest.

Following steps here, "online" method for LVM involves using Parted's command "resizepart". Problem is, Centos 7 uses a Parted version with "resizepart" *removed*, so it will simply NOT work.
Seemingly that function, along with others, was removed since version 2.4 -according to this-, but was restored much later in version 3.2. Version 3.1 was the only one shipped on Centos 7.
Is there a solution for this, either "online" or "offline"?

Also, regarding the mentioned "online" method for non-LVM, what if partition is different from ext2/3/4, say, xfs? Is Gparted "offline" method the only option in this case?

Thanks.
 
I mean, more generally, this Proxmox official doc says nothing of what to do in case of:

--guest OS is using a Parted version lacking the "resizepart" command; and since Gparted doesn't support LVM, how to do then?
--guest OS partition is not ext2/3/4; thus "online" method at very end of page will not work.
 
Last edited:
--guest OS is using a Parted version lacking the "resizepart" command; and since Gparted doesn't support LVM, how to do then?
the tools in the guide are only suggestions, and most often there are alternatives available, for example you should be able to use fdisk/gdisk/etc to grow the partition
lvm has its native tooling namely lvextend, vgextend, pvresize

--guest OS partition is not ext2/3/4; thus "online" method at very end of page will not work.
how to do that depends on the exact filesystem, in any case you should check the manuals/docs of your guest os

what should always be possible is to do that offline, e.g. with a live linux cd
 
Personnaly, I don't use partition, but directly format raw drive (mkfs.xfs /dev/sdb for example).

then, after resizing for proxmox gui, you can simply do "xfs_growfs /yourmountpoint"

It's also possible to automate it with an udev rule in guest os like:

Code:
/etc/udev/rules.d/90-resizefs.rules
ACTION=="change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", RUN+="/usr/local/bin/resizefs.sh"

Code:
#!/bin/bash

if [ -n "$DEVNAME" ]; then

    if [ "$ID_FS_TYPE" == "ext4" ] || [ "$ID_FS_TYPE" == "ext3" ]; then
        resize2fs $DEVNAME
    fi

    if [ "$ID_FS_TYPE" == "xfs" ]; then
        MOUNTPOINT=`lsblk -o MOUNTPOINT -nr $DEVNAME`
        if [ -n "$MOUNTPOINT" ]; then
            xfs_growfs $MOUNTPOINT
        fi
    fi
fi



if you use partition (/dev/sda1 , /dev/sdb2).
it's possible to onlne extend the last partition of the disk with "growpart". (available in cloud-init packages)
https://access.redhat.com/solutions/5540131
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!