Comment 10 for bug 906722

Revision history for this message
Scott Moser (smoser) wrote :

I'll fix this in cloud-initramfs-tools because its just cleaner to do there. I was calling growpart while the disk was mounted simply to optimize the case where there was a change to be made (which happens only the first boot, really).

Instead, I'm just going to call growpart once with '--debug' and if it would not make a change, then exit as before.
If it *would* make a change, then unmount / and call it again to make the change.

 but there are some issues with sfdisk, and the update made it worse.
 * --no-reread option exists in older versions of util-linux (at least in 2.19)
 * --no-reread and --force with a mounted filesystem still exits failure in 2.20, it did not in 2.19

Partition is mounted and disk not resized (system booted) at this point.

$ growpart /dev/vda 1 --dry-run 2>out
CHANGE: partition=1 start=16065 old: size=4176900 end=4192965 new: size=20948760,end=20964825
$ sed -n '/new sfdisk/,$p' err > new
$ cat new
# === new sfdisk -d ===
# partition table of /dev/vda
unit: sectors

/dev/vda1 : start= 16065, size= 20948760, Id=83, bootable
/dev/vda2 : start= 0, size= 0, Id= 0
/dev/vda3 : start= 0, size= 0, Id= 0
/dev/vda4 : start= 0, size= 0, Id= 0

$ sudo sfdisk /dev/vda --force --no-reread < new; echo $?
....
Successfully wrote the new partition table
Re-reading the partition table ...
BLKRRPART: Device or resource busy
...
1

Previously if we did --force it would exit success (i guess in all cases).