Resize a GPT virtual disk

Resize a GPT virtual disk

After the reinstallation of my multimedia server i created a too small vdisk, no problemo i use LVM, simply resize the disk in proxmox, recreate your PV partition and pvresize, that's it.

Surprise, you can't resize your LVM PV partition if you have a GPT partition table because GPT put his backup structure at the end of the disk.

Disk /dev/vdb: 3774873600 sectors, 1.8 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): C720DBB4-0888-42EC-8C26-6A4B67199931
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 2097151966

As you can see the disk is 3774873600 sectors but only (2097151966 - 34) is usable.

We can fix this by using gdisk entering in the expert mode with "x" and "e" (relocate backup data structures to the end of the disk).

gdisk /dev/vdb

> x
> e

Now we have all our sector usable.

Disk /dev/vdb: 3774873600 sectors, 1.8 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): C720DBB4-0888-42EC-8C26-6A4B67199931
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 3774873566

After that follow the basic steps to resize your LVM PV.