NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Resizing a GPT disk, for the record



On Tue, 6 Oct 2015, Stephen Borrill wrote:
On Thu, 18 Jun 2015, Stephen Borrill wrote:
On Wed, 17 Jun 2015, John Nemeth wrote:
On Jun 17,  1:49pm, Stephen Borrill wrote:
}
} For the record, I'm presenting a transcript of dealing with a
} resized virtual disk with a GPT table. The disk has been resized
} from 10G to 20G. Note the secondary GPT table cannot be located
} because it is no longer at the end of the disk.

    If you resize the media, you should use "gpt resizedisk".
That will either relocate the secondary GPT, or create a new one.
It will also update all size fields for the new media size, and
adjust the pointer to the secondary GPT.  "gpt recover" does not
do these steps, it simply copies whichever GPT exists to the other
one.

I think my NetBSD 7 install just predated the big gpt pullup by a matter of hours. I downloaded it from the autobuild cluster on 2nd June from the latest build which was the same day the pullup happened... So I did not have gpt resizedisk.

} (aside: when I first did this, after the recover step the free space was
} no longer listed. I could not repeat this, but I expect a gpt resize -s

    Likely due to incorrect data in the GPT header.

} <existing size> -i 1 xbd1 would have brought it back).

    Uh, why?  "gpt resize" doesn't touch anything except the
partition that's being resized, and update CRCs.  Your suggested
command does nothing, except print a message saying that nothing
needs to be done.

The reason I suggested is that it worked on the one time the free space disappeared, but as I couldn't repeat it, I could not be certain.

Anyway, thanks for the heads up about gpt resizedisk.

So now I've updated to 7.0 release and it's completely broken:

builder7# gpt resizedisk xbd1
gpt: rxbd1d: error: no secondary GPT header; run recover
builder7# gpt recover xbd1
gpt: rxbd1d: media size has changed, please use 'gpt resizedisk'

Haven't had chance to dig in the source yet.

And now my final follow-up on the subject. John suggested to use gpt backup followed by gpt restore -F as gpt restore makes the assumption that you might not be restoring to the same size disk so it adjusts everything required for destination disk size. This followed the discovery that using the new gpt header subcommand in HEAD demonstrated the total size was very wrong. Look at the Last Data Sector:

Media Size: 32212254720 (30G)
Sector Size: 512
Number of Sectors: 62914560 (60M)

Header Information:
- GPT Revision: 65536
- First Data Sector: 34
- Last Data Sector: 20971486 (20M)
- Media GUID: 8f7dbf92-0f7f-11e5-895b-5acb6b8c1887
- Number of GPT Entries: 128

This was never adjusted on my first resize (from 10GB to 20GB). After the backup/restore dance it is now consistent:

Media Size: 32212254720 (30G)
Sector Size: 512
Number of Sectors: 62914560 (60M)

Header Information:
- GPT Revision: 65536
- First Data Sector: 34
- Last Data Sector: 62914526 (60M)
- Media GUID: 8f7dbf92-0f7f-11e5-895b-5acb6b8c1887
- Number of GPT Entries: 128

--
Stephen



Home | Main Index | Thread Index | Old Index