Another question addresses a scenario where truncate
damages an image of a GPT drive. If I understand correctly, the advice there is to use gdisk
to repair the damage. I would rather not cause the damage in the first place.
I have a Windows 10 installation on a 256GB USB GPT drive. I've used a Windows partitioner (MiniTool Partition Wizard) to squeeze the partitions down to a size that will fit onto a 128GB drive. This is what I want to image.
I can use Gnome Disks to create a 256GB raw image. But, as above, using truncate
to reduce that to 128GB - to get rid of ~128GB of unallocated space at the end - will apparently damage the GPT partitioning.
As far as I can tell gdisk
is looking for partitions to work with. I could convert the 128GB unallocated space into a partition, and then use gdisk
to delete it - but won't that just return me to having 128GB unallocated on disk?
I guess I'm asking whether there's a truncate
-like tool or technique for GPT.
gdisk
or more user friendly withgpt-fix
according to this link. Explanation: when the size is different, the backup gpt-table must be rewritten (to the tail end of the target drive). Allow a small margin, 1 MB is more than enough, from the tail end of the last partition to the tail end of the drive. – sudodus Oct 02 '23 at 11:47