GPT online disk enlarge

I am going from MBR disks to GPT disks and I am having problems online enlarging the GPT disk. I do not use LVM. I had a way of doing that online with MBR but with GPT he complains about the backup GPT table not being at the end of the disk. Can someone give me a clue on how to properly online enlarge a GPT disk/partition? Partition on it is EXT4 at the moment. I can get it to work when parted fixes the problem but I want to script it and that seems not possible at this moment.

Hi and welcome to the Forum :slight_smile:
You would need to look at sgdisk, partprobe and resize2fs…

For sgdisk the -e option would move the second header to the end of the disk, then recreate your partition and resize as required.

Perhaps some details of the disk/partitions in question?

This is a test system to try on, not a production one?

The disk is a regular disk in vmware. It is on a test system because I am still searching for the right procedure. It is a datadisk mounted at a non default directory. Ext4 is the filesystem.

I actually have a procedure for MBR disks and wanted to make the same for GPT disks.

  • vmware enlarge disk
  • rescan disk : echo 1 > /sys/block/sdX/device/rescan
  • fdisk : delete then new partition
  • reread partition table: partx - u /sdX
  • enlarge filesystem : resize2fs /dev/sdX1

The first two steps are working fine. But for the third step I wanted to use gdisk. And there it failed (the partition I could make was exactly the same as before, so not bigger). Then I used parted and it told me to fix the disk because the backup GPT table was not at the end of the disk. After parted fixed it, I went back to gdisk and did the same as in fdisk for MBR.

After that I tried partprobe but that didnt work (said the system was still busy, it was mounted) but partx worked. As did resize2fs.

So I actually managed to do the online enlarge but I cannot script this way. It is kind of a big detour which I want to avoid.

I will have a look at sgdisk. Thank you.