Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Dec 2016 19:28:19 +0300
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        Slawa Olhovchenkov <slw@zxy.spb.ru>, freebsd-hackers@freebsd.org
Subject:   Re: How to safely remove rest of GTP?
Message-ID:  <d79b8568-72e8-415e-4923-14e3c730267e@FreeBSD.org>
In-Reply-To: <20161230124407.GN37118@zxy.spb.ru>
References:  <20161230124407.GN37118@zxy.spb.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------ECE39D6E59BD255AAD9727C9
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

On 30.12.2016 15:44, Slawa Olhovchenkov wrote:
> How to safely remove rest of GPT?
> Disk have actual data (part of ZFS), I am don't need to destroy this
> data.
>
> GEOM: da6: the primary GPT table is corrupt or invalid.
> GEOM: da6: using the secondary instead -- recovery strongly advised.
> GEOM: da22: the primary GPT table is corrupt or invalid.
> GEOM: da22: using the secondary instead -- recovery strongly advised.
> GEOM: da6: the primary GPT table is corrupt or invalid.
> GEOM: da6: using the secondary instead -- recovery strongly advised.
> GEOM: da22: the primary GPT table is corrupt or invalid.
> GEOM: da22: using the secondary instead -- recovery strongly advised.

You may try attached patch, I did only basic tests, so first try 
somewhere :)

-- 
WBR, Andrey V. Elsukov

--------------ECE39D6E59BD255AAD9727C9
Content-Type: text/x-patch;
 name="gpart_safe_destroy.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="gpart_safe_destroy.diff"

Index: sys/geom/part/g_part_gpt.c
===================================================================
--- sys/geom/part/g_part_gpt.c	(revision 310784)
+++ sys/geom/part/g_part_gpt.c	(working copy)
@@ -690,7 +690,8 @@ g_part_gpt_destroy(struct g_part_table *basetable,
 	 * Wipe the first 2 sectors to clear the partitioning. Wipe the last
 	 * sector only if it has valid secondary header.
 	 */
-	basetable->gpt_smhead |= 3;
+	if (table->state[GPT_ELT_PRIHDR] == GPT_STATE_OK)
+		basetable->gpt_smhead |= 3;
 	if (table->state[GPT_ELT_SECHDR] == GPT_STATE_OK &&
 	    table->lba[GPT_ELT_SECHDR] == pp->mediasize / pp->sectorsize - 1)
 		basetable->gpt_smtail |= 1;

--------------ECE39D6E59BD255AAD9727C9--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d79b8568-72e8-415e-4923-14e3c730267e>