growpart command fails with error "FAILED: pt_resize failed"
Environment
- Red Hat Enterprise Linux 7
- cloud-utils-growpart-0.29-2.el7
Issue
growpart
command fails with error "FAILED: pt_resize failed"
[root@localhost ~]# parted /dev/sda u s p
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sda: 41943040s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 2048s 1953791s 1951744s primary ext4 boot
2 1953792s 19531250s 17577459s primary lvm
3 19531251s 39062501s 19531251s primary
[root@localhost ~]# growpart /dev/sda 3
failed [pt_update:1] pt_update /dev/sda 3
partx: /dev/sda: updating partition #3 failed: Invalid argument
partx: /dev/sda: error updating partition 3
partition: none, disk: /dev/sda, lower: 3, upper: 3
/dev/sda: partition table type 'dos' detected
/dev/sda: partition #3 resized
FAILED: pt_resize failed
***** WARNING: Resize failed, attempting to revert ******
Re-reading the partition table ...
BLKRRPART: Device or resource busy
sfdisk: The command to re-read the partition table failed.
Run partprobe(8), kpartx(8) or reboot your system now,
before using mkfs
Resolution
- This issue is currently being tracked in Bug 1593451 - growpart fails when partition start sector is the same as partition size
- As a workaround, the partition will need to be manipulated manually. For assistance with this, please contact Red Hat Support
Root Cause
There is a bug in the growpart script. The sed
command shown below picks out the line needed and replaces the old number with the new. However, if the number exists more than once on the line, it replaces only the first number (in this case, the start sector of the partition), rather than the size.
sed "\|^\s*${dpart} |s/${pt_size},/${new_size},/" "${dump_out}" \
>"${new_out}" ||
fail "failed to change size in output"
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments