From owner-freebsd-geom@FreeBSD.ORG Tue Oct 19 18:15:42 2010 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A283B106566C; Tue, 19 Oct 2010 18:15:42 +0000 (UTC) (envelope-from bu7cher@yandex.ru) Received: from forward10.mail.yandex.net (forward10.mail.yandex.net [77.88.61.49]) by mx1.freebsd.org (Postfix) with ESMTP id 346F98FC18; Tue, 19 Oct 2010 18:15:41 +0000 (UTC) Received: from smtp8.mail.yandex.net (smtp8.mail.yandex.net [77.88.61.54]) by forward10.mail.yandex.net (Yandex) with ESMTP id 5727F1F50571; Tue, 19 Oct 2010 22:15:40 +0400 (MSD) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1287512140; bh=uSAsLV3CSsdfWW6v/bZUkLu2OVhqyZ2uuiWGBun5lKU=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type; b=SVF9DJt9UGP2VX5bJ6raxYX/iYfu11iJo1O9pJ+36/yU92DPwY4363dS7OY4m1Npi mFRkSKRIbRVx3n0lmbsNo7Kxd7ZVhD9YLBxAyxieBR/7d53ewYtE2tBWVwSLm8wng/ hl8Bbgt5oIhhtiDjUK7nsvnjMs8TNpY7qDtBJGYg= Received: from [10.43.163.197] (nat-77-30.kirovnet.ru [92.39.77.30]) by smtp8.mail.yandex.net (Yandex) with ESMTPSA id CB33F202809D; Tue, 19 Oct 2010 22:15:39 +0400 (MSD) Message-ID: <4CBDE012.8030000@yandex.ru> Date: Tue, 19 Oct 2010 22:14:42 +0400 From: "Andrey V. Elsukov" User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.9) Gecko/20100925 Thunderbird/3.1.4 MIME-Version: 1.0 To: Marcel Moolenaar References: <4CB850CC.4040206@yandex.ru> <4CB8587F.3010401@yandex.ru> In-Reply-To: X-Enigmail-Version: 1.1.2 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigD80D9AA90D326A186800A0AD" X-Yandex-TimeMark: 1287512140 X-Yandex-Spam: 1 X-Yandex-Front: smtp8.mail.yandex.net Cc: Konstantin Belousov , Alexander Motin , Marcel Moolenaar , Pawel Jakub Dawidek , freebsd-geom@freebsd.org Subject: Re: [RFC][patch] GPT recovering support X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Oct 2010 18:15:42 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigD80D9AA90D326A186800A0AD Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: quoted-printable On 15.10.2010 20:15, Marcel Moolenaar wrote: > It's better to implement a force option to destroy that forces > a scheme to be destroyed in a way that prevents undo. This > allows you to (effectively) wipe sectors and start over. This > is exactly what you want if you're stuck with a detected scheme > that is corrupt to the point that you can't do anything with I rewrite forced destroying. Now it does all work in kernel. http://people.freebsd.org/~ae/gpart_recover_20101019.diff > It would be good if you can list the corruption cases that are > being handled and how you recover. While we need to be friendly > to the GEOM flexibility, we do need to respect the GPT spec > to the extend that we remain compatible. 1. Wiped first several sectors. //------------------------------------------------------------ # truncate -s 100m disk # mdconfig -f disk md0 # gpart create -s gpt md0 md0 created # gpart add -t freebsd md0 md0s1 added # gpart show md0 =3D> 34 204733 md0 GPT (100M) 34 204733 1 freebsd (100M) # dd if=3D/dev/zero of=3D/dev/md0 bs=3D512 count=3D10 10+0 records in 10+0 records out 5120 bytes transferred in 0.169473 secs (30211 bytes/sec) # gpart show md0 gpart: No such geom: md0. // First of we should rewrite PMBR. # dd if=3D/boot/pmbr of=3D/dev/md0 1+0 records in 1+0 records out 512 bytes transferred in 0.046906 secs (10915 bytes/sec) GEOM: md0: the primary GPT table is corrupt or invalid. GEOM: md0: using the secondary instead -- recovery strongly advised. # gpart show md0 =3D> 34 204733 md0 GPT (100M) [CORRUPT] 34 204733 1 freebsd (100M) # gpart status md0 Name Status Components md0s1 CORRUPT md0 // Now we can recover it # gpart recover md0 md0 recovered # gpart show md0 =3D> 34 204733 md0 GPT (100M) 34 204733 1 freebsd (100M) //------------------------------------------------------------ 2. Wiped last several sectors. //------------------------------------------------------------ # gpart list md0 | grep last last: 204766 # dd if=3D/dev/zero of=3D/dev/md0 bs=3D512 oseek=3D204767 dd: /dev/md0: end of device 34+0 records in 33+0 records out 16896 bytes transferred in 0.345195 secs (48946 bytes/sec) GEOM: md0: the secondary GPT table is corrupt or invalid. GEOM: md0: using the primary only -- recovery suggested. # gpart show md0 =3D> 34 204733 md0 GPT (100M) [CORRUPT] 34 204733 1 freebsd (100M) // We can recover this GPT again, also we can destroy it. // But we can not modify it. # gpart delete -i 1 md0 gpart: table 'md0' is corrupt: Operation not permitted # gpart modify -i 1 -l TEST -f x md0 gpart: table 'md0' is corrupt: Operation not permitted # gpart destroy md0 gpart: Device busy # gpart destroy -F md0 md0 destroyed # gpart show md0 gpart: No such geom: md0. //------------------------------------------------------------ 3. Changed mediasize. //------------------------------------------------------------ # gpart create -s gpt md0 md0 created # gpart add -t freebsd md0 md0s1 added # gpart show md0 =3D> 34 204733 md0 GPT (100M) 34 204733 1 freebsd (100M) # mdconfig -du 0 # truncate -s +10m disk # mdconfig -f disk md0 GEOM: md0: the secondary GPT header is not in the last LBA. # gpart show md0 =3D> 34 204733 md0 GPT (110M) [CORRUPT] 34 204733 1 freebsd (100M) // Secondary GPT header must be in the last LBA. // When it is not here you can lost GPT if primary copy will // become corrupt. Also you may want to extend your table to // all mediasize. # gpart list md0 | grep last last: 204766 # gpart recover md0 md0 recovered # gpart list md0 | grep last last: 225246 # gpart show md0 =3D> 34 225213 md0 GPT (110M) 34 204733 1 freebsd (100M) 204767 20480 - free - (10M) //------------------------------------------------------------ 4. As the side effect now some of tasted copies of the same table will be read-only. //------------------------------------------------------------ # gpart destroy -F md0 md0 destroyed # glabel label -v TEST md0 Metadata value stored on md0. Done. # gpart create -s gpt label/TEST label/TEST created # gpart show =3D> 34 225212 label/TEST GPT (110M) 34 225212 - free - (110M) =3D> 34 225212 md0 GPT (110M) [CORRUPT] 34 225212 - free - (110M) # gpart add -t freebsd-ufs md0 gpart: table 'md0' is corrupt: Operation not permitted # gpart add -t freebsd-ufs label/TEST label/TESTp1 added # gpart show =3D> 34 225212 label/TEST GPT (110M) 34 225212 1 freebsd-ufs (110M) //------------------------------------------------------------ Any comments? --=20 WBR, Andrey V. Elsukov --------------enigD80D9AA90D326A186800A0AD Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (FreeBSD) iQEcBAEBAgAGBQJMveAaAAoJEAHF6gQQyKF6GPMIAIaW+GryGdicbY6oSGtOfIAP vw5HcAFz7/Fnlljc2cZj2FiAG5nZJz8QFK5Dy18Oe5u4fKP0//vWmaioT9dUnZqc 9PPxdQQbqP2WWdiUGfX825lOINRF0NsXyywZoQFmL9OsxAaKA8bTv5opG1vxODPQ E1Xnw3komFlK0Oq1txbDR5/OVxvQmcaBJGMNroBifGszObnqdiYygrPlg7A9NqXH tx38JlYqa0tDBdW0Ff5miif/OVI98PKYgqe2SqRuKVJwlsFardF75R6VXG5K9IGQ OQop86PLZiROwnfREIudnmbcWl0FnpPSKWn8oBj6hy2LIE4iMHWY3ngmbilJ2P4= =fET1 -----END PGP SIGNATURE----- --------------enigD80D9AA90D326A186800A0AD--