Date: Tue, 19 Oct 2010 22:14:42 +0400 From: "Andrey V. Elsukov" <bu7cher@yandex.ru> To: Marcel Moolenaar <xcllnt@mac.com> Cc: Konstantin Belousov <kib@freebsd.org>, Alexander Motin <mav@freebsd.org>, Marcel Moolenaar <marcel@freebsd.org>, Pawel Jakub Dawidek <pjd@FreeBSD.org>, freebsd-geom@freebsd.org Subject: Re: [RFC][patch] GPT recovering support Message-ID: <4CBDE012.8030000@yandex.ru> In-Reply-To: <DED1396D-89AA-4217-9EAE-175750C47DE1@mac.com> References: <4CB850CC.4040206@yandex.ru> <4CB8587F.3010401@yandex.ru> <DED1396D-89AA-4217-9EAE-175750C47DE1@mac.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4CBDE012.8030000>