parted allows to fix broken GPT only interactively
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| | parted (Ubuntu) |
Low
|
Unassigned | ||
Bug Description
when physically resizing a disk (i.e. because it is a kvm image where you dd zeros to the end or because you dd'ed an image from a smaller disk to a bigger one) the GPT backup at the end of the device sits in the wrong sectors ...
while parted offers you a yes/no question in interactive mode to fix this, there is no way to make use of this feature when using "parted -s" (scripted mode). parted should get an option to fix the GPT even when using it non-interactively i.e. from a "grow rootfs at first boot to full disk size" script.
| Michael Vogt (mvo) wrote : | #1 |
| Oliver Grawert (ogra) wrote : | #2 |
it is in libparted/
1033 q = ped_exception_throw
1034 (PED_EXCEPTION_
1035 PED_EXCEPTION_FIX | PED_EXCEPTION_
1036 _("Not all of the space available to %s appears "
1037 "to be used, you can fix the GPT to use all of the "
1038 "space (an extra %llu blocks) or continue with the "
1039 "current setting? "), disk->dev->path,
1040 (uint64_t) (last_usable_
that gets me a "Fix/Ignore" prompt.
| Launchpad Janitor (janitor) wrote : | #3 |
Status changed to 'Confirmed' because the bug affects multiple users.
| Changed in parted (Ubuntu): | |
| status: | New → Confirmed |
| Phillip Susi (psusi) wrote : | #4 |
I've been aware of this for a few years now since I first added the feature and sebner wanted to use it in the cloud-init-tools to do just that. The problem is that the exception handler only gets a text description, so you would need to do a loose string comparison to identify the particular exception you want to auto accept. You then need a way to specify this with a command line switch. I'm not liking the idea of parted --force-
Also the exact text is subject to change between releases, and changes depending on your locale, so it gets really tricky.
| Changed in parted (Ubuntu): | |
| status: | Confirmed → Triaged |
| importance: | Undecided → Low |
| Oliver Grawert (ogra) wrote : | #5 |
ugh, indeed i didnt mean to have the cmdline option hooked to the text handler but simply have it run whatever gets executed to fix the gpt without interaction or anything ...
we currently need to use an awfully hackish workaround to do the auto-resize on snappy images (store original table, create a brand new gpt and restore the old table) and i would like to somehow fix this before the next stable snappy release (in 4-8 weeks). i could indeed switch to gdisk but i'd really rather like to use parted as it is the traditionally used partitioning tool in ubuntu.
| Oliver Grawert (ogra) wrote : | #6 |
oh, and note that i know beforehand that there is a GPT and that i want to resize (and i even know the GPT backup wont sit at the end), i have all that info before attempting to run parted, so in my specific case i wouldn't need the exception handler at all.
| Phillip Susi (psusi) wrote : | #7 |
The fix code gets run based on the response the exception handler gives. The exception handler returns the default answer for all exceptions when in script mode, and the default for that one is not to fix it. Thus, to get it to say yes, fix it, you need the exception handler to recognize the specific exception and return the fix it response.
There is another way of accomplishing what you want though and that is to fake interactive mode. If you pass, I believe it was ---pretend-
I suppose the other option is to change the default for that error to fix. I didn't do that originally because there are times when that might be the wrong thing to do and it could cause data loss, so didn't seem appropriate to do without user consent.
| Oliver Grawert (ogra) wrote : | #8 |
oh, thats awesome, i'll play with --pretend-
i think it already prints the error for the print command so i can run that first and separated from the actual actions (locales wont be an issue inside the initrd)
| Phillip Susi (psusi) wrote : | #9 |
Also I *think* that if you just don't use -s, you can put the "fix" command right on the command line following the print command and that will do it, but that behavior is really a bug in itself that I was planning on fixing at some point.


What exactly is the message you get in interactive mode? this would help track down the relevant code.