Extending a volume online

Posted by & filed under Server Admin.

I was attempting to resize a GPT partition ( http://natesbox.com/blog/extending-logical-volume-online/ ). Expanded the physical disk from 4TB to 6TB. Found that fdisk reported the disk size to be 6TB, but would not let me use any of the additional sectors:

Disk /dev/sda: 6 TiB, 6597069766656 bytes, 12884901888 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: E3374C46-FDAA-4FA0-AFD2-1C861700B6EA

Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 503807 499712 244M Linux filesystem
/dev/sda3 503808 8589932543 8589428736 4T Linux LVM

Note the disk says it has 12884901888 sectors, but I can’t expand it past the 8589428736’th sector of /dev/sda3

Running the v command in fdisk reports:

Command (m for help): v
MyLBA mismatch with real position at backup header.
1 error detected.

Found this article: serverfault.com/questions/833231/after-h…

This recommends using gdisk to repair the issue as the backup partition table wasn’t moved to the end of the new geometry:

root@mdm-backup-01:~# gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.1

Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): r

Recovery/transformation command (? for help): v

Problem: The secondary header’s self-pointer indicates that it doesn’t reside
at the end of the disk. If you’ve added a disk to a RAID array, use the ‘e’
option on the experts’ menu to adjust the secondary header’s and partition
table’s locations.

Identified 1 problems!

Recovery/transformation command (? for help): x

Expert command (? for help): e
Relocating backup data structures to the end of the disk

Expert command (? for help): v

No problems found. 4294971325 free sectors (2.0 TiB) available in 2
segments, the largest of which is 4294969311 (2.0 TiB) in size.

Expert command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.