5

I'd like to extend my virtual disk in a Proxmox environment from 64GB to 100GB. The guest OS is Debian 10. I've extended the virtual disk in Proxmox (it now has 100GB) and restarted the guest OS.

cfdisk correctly sees that the size of the disk is now 100GiB:

                                             Disk: /dev/vda
                          Size: 100 GiB, 107374182400 bytes, 209715200 sectors
                                   Label: dos, identifier: 0x9f2b12a1

    Device           Boot               Start           End       Sectors      Size     Id Type
>>  /dev/vda1        *                   2048        499711        497664      243M     83 Linux
    /dev/vda2                          501758     134215679     133713922     63.8G      5 Extended
    └─/dev/vda5                        501760     134215679     133713920     63.8G     8e Linux LVM
    Free space                      134215680     209715199      75499520       36G

However I'm unable to extend either vda2 or vda5 with the following error messages:

  • /dev/vda2: Maximum size is 68461528064 bytes
  • /dev/vda5: Failed to resize partition #5.

Any ideas what could be wrong?

1
  • exact same problem - Ubuntu 20.04
    – gies0r
    Commented May 10, 2021 at 18:31

3 Answers 3

0

I had the same problem.

I solved it by creating a new partition via cfdisk and then created a new physical volume via pvcreate /dev/sda3. I added this new pv to the my volume group: vgextend /dev/VMTEMPLATE-vg /dev/sda3.

The VG should now be the correspondingly enlarged. Then I resized the logical volume: lvresize /dev/VMTEMPLATE-vg/root /dev/sda3.

Finally I adjusted the size of the filesystem: resize2fs /dev/mapper/VMTEMPLATE--vg-root.

0

In VMWare

Edit VM guest and add some disk space to the first disk and save.

Run cfdisk to utilize the free space

$ sudo cfdisk

Create a new partition from the free space. In my case it was /dev/sda3

Create new physical volume

$ sudo pvcreate /dev/sda3

Physical volume "/dev/sda3" successfully created.

Add the new physical volume to my volume group

$ sudo vgextend /dev/transfer-vg /dev/sda3

Volume group "transfer-vg" successfully extended

Resize logical volume

$ sudo lvresize /dev/transfer-vg/root /dev/sda3

Size of logical volume transfer-vg/root changed from <5.52 GiB (1413 extents) to <17.52 GiB (4485 extents). Logical volume transfer-vg/root successfully resized.

Find the name of filesystem to be resized

$ df -hT | grep mapper

/dev/mapper/transfer--vg-root ext4 5.4G 4.2G 911M 83% /

/dev/mapper/transfer-data ext4 79G 14G 61G 19% /var/www/data

resize filesystem

$ sudo resize2fs /dev/mapper/transfer--vg-root

resize2fs 1.44.1 (24-Mar-2018) Filesystem at /dev/mapper/transfer--vg-root is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 2 The filesystem on /dev/mapper/transfer--vg-root is now 4592640 (4k) blocks long.

0

cfdisk may not let you resize the partition because it contains other partitions in use. Instead you can use a tool that can do things at low level: parted

Warning: Take a VM snapshot in advance as you could lose data if you do things wrong. There's no write, save or undo.

In parted console type resizepart <PART_NUMBER> <NEW_END_POSITION>

Notice that you set the end position of the partition and not the size. For example, in the sample below, the extended partition 2 is resized to use the remaining free space at the end of the disk.

(parted) print free                                                       
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type      File system  Flags
        32.3kB  1049kB  1016kB            Free Space
 1      1049kB  300MB   299MB   primary   ext2         boot
        300MB   301MB   1048kB            Free Space
 2      301MB   12.9GB  12.6GB  extended
 5      301MB   12.9GB  12.6GB  logical                lvm
        12.9GB  21.5GB  8591MB            Free Space

(parted) resizepart 2 21.5GB                                              

(parted) print free                                                       
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type      File system  Flags
        32.3kB  1049kB  1016kB            Free Space
 1      1049kB  300MB   299MB   primary   ext2         boot
        300MB   301MB   1048kB            Free Space
 2      301MB   21.5GB  21.2GB  extended
 5      301MB   12.9GB  12.6GB  logical                lvm
        12.9GB  21.5GB  8591MB            Free Space

As you can see, the end of partition 2 matches the end of free space. After this, you can go to the friendly cfdisk to create the new logical partition.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .