[Gptfdisk-general] [GPTfdisk][PATCH] Adding support for GPT recovery using sgdisk
Brought to you by:
srs5694
|
From: abhisek s. <abh...@gm...> - 2014-03-24 08:28:36
|
Hi Roderick/Yves,
The patch provided in the earlier email does not work with the
latter release. I have corrected the patch for version 0.8.10.
I have tested the following scenarios:
1. Primary GPT wiped out. Primary GPT successfully restored from the
Secondary GPT.
2. Secondary GPT wiped out. Secondary GPT header successfully restored
from Primary GPT header.
Following is the patch for you reference:
diff -u old/gptcl.cc new/gptcl.cc
--- old/gptcl.cc 2014-03-02 23:27:37.000000000 +0530
+++ new/gptcl.cc 2014-03-24 13:53:00.068018600 +0530
@@ -90,6 +90,7 @@
{"load-backup", 'l', POPT_ARG_STRING, &backupFile, 'l', "load
GPT backup from file", "file"},
{"list-types", 'L', POPT_ARG_NONE, NULL, 'L', "list known
partition types", ""},
{"gpttombr", 'm', POPT_ARG_STRING, &mbrParts, 'm', "convert GPT
to MBR", "partnum[:partnum...]"},
+ {"fixgptcorruption", 'M', POPT_ARG_NONE, NULL, 'M', "Restores
the corrupt primary or secondary GPT header"},
{"new", 'n', POPT_ARG_STRING, &newPartInfo, 'n', "create new
partition", "partnum:start:end"},
{"largest-new", 'N', POPT_ARG_INT, &largestPartNum, 'N',
"create largest possible new partition", "partnum"},
{"clear", 'o', POPT_ARG_NONE, NULL, 'o', "clear partition table", ""},
@@ -281,6 +282,11 @@
saveData = 0;
} // if
break;
+ case 'M':
+ JustLooking(0);
+ saveData = 1;
+ retval = 0;
+ break;
case 'n':
JustLooking(0);
newPartNum = (int) GetInt(newPartInfo, 1) - 1;
@@ -427,6 +433,11 @@
free(backupFile);
retval = 0;
break;
+ case 'M':
+ JustLooking(0);
+ saveData = 1;
+ retval = 0;
+ break;
case 'o':
JustLooking(0);
ClearGPTData();
The benefit of having this option is that corrupt Primary/Secondary
GPT headers can be restored using a command line i.e. sgdisk. This
makes it easier to be used by programs/shell scripts. Kindly let me
know you views.
Thanks,
Abhisek
---------- Forwarded message ----------
From: abhisek shaw <abh...@gm...>
Date: Fri, Mar 14, 2014 at 3:30 PM
Subject: Adding support for GPT recovery using sgdisk
To: gpt...@li...
Hi All,
The sgdisk utility currently lacks options for correcting the
Primary/Secondary GPT headers if there is any corruption If the
Primary GPT header is corrupted, it could be updated from the
Secondary GPT header and vice-verse.
I have prepared a patch for this(PFA). Kindly review it and add it the sources.
Please do let me if there are additional changes required. This patch
has been prepared on the latest version of the code i.e. 0.8.10
Thanks,
Abhisek
|