From owner-freebsd-geom@FreeBSD.ORG Wed Nov 13 04:55:50 2013 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 992BC4DA for ; Wed, 13 Nov 2013 04:55:50 +0000 (UTC) Received: from alogt.com (alogt.com [69.36.191.58]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 77AE32244 for ; Wed, 13 Nov 2013 04:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=alogt.com; s=default; h=Content-Transfer-Encoding:Content-Type:Mime-Version:References:In-Reply-To:Message-ID:Subject:Cc:To:From:Date; bh=t/Ztiqak/Qyf3OtMI7bQuQtBk6ehpFqlrH32LsSK+Po=; b=nYjVfPVjUimPWp0ZVBd1xgBHlSgYzuYN0rit1oYExlwgqN/H6Pe67M1Z6TpyaHnj38LFjuTYLu4P8UEQsY7SDLS0bqXkdZD7kyqrQL1sAIsdiLA7e8BoYycDxyPs5oC7XIDRlfG0OfNe3tGvnfMJ/KPpy1ZdPRgncpSnkEp8SAQ=; Received: from [182.11.142.138] (port=49221 helo=X220.ovitrap.com) by sl-508-2.slc.westdc.net with esmtpsa (SSLv3:DHE-RSA-AES128-SHA:128) (Exim 4.80.1) (envelope-from ) id 1VgSUP-003JfR-Ng; Tue, 12 Nov 2013 21:55:43 -0700 Date: Wed, 13 Nov 2013 12:55:36 +0800 From: Erich Dollansky To: symbolics@gmx.com Subject: Re: documentation of GEOM data structures needed Message-ID: <20131113125536.01a43e4b@X220.ovitrap.com> In-Reply-To: <20131112094050.GA1808@lemon> References: <20131111162400.0bc7dfef@X220.ovitrap.com> <20131111091836.GA83261@lemon> <20131111183216.5ec80e9e@X220.ovitrap.com> <20131111151141.GA1381@lemon> <20131111235032.6a6f26f7@X220.ovitrap.com> <20131111164805.GB1381@lemon> <20131112111658.4cb1ef95@X220.ovitrap.com> <20131112094050.GA1808@lemon> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.19; amd64-portbld-freebsd10.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - sl-508-2.slc.westdc.net X-AntiAbuse: Original Domain - freebsd.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - alogt.com X-Get-Message-Sender-Via: sl-508-2.slc.westdc.net: authenticated_id: erichsfreebsdlist@alogt.com X-Source: X-Source-Args: X-Source-Dir: Cc: freebsd-geom@freebsd.org X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Nov 2013 04:55:50 -0000 Hi, On Tue, 12 Nov 2013 09:40:50 +0000 symbolics@gmx.com wrote: > On Tue, Nov 12, 2013 at 11:16:58AM +0800, Erich Dollansky wrote: > > > > > > In which case run `gpart backup da1' (assuming da1 is the name of > > > one of the intact discs). You can store the output text to a file > > > and then edit it to fit. Then use `gpart restore da0' to apply it > > > to the new disc. > > > > > > First of all, take backups of your existing MBRs, just in case: > > > > > I copied already the identified data structures into files. > > > > > # gpart backup da1 > ~/da1.gpart > > > > This is what I would like to avoid. I would like to understand how > > it works and do it manually. > > The code is in sys/geom and sbin/geom. The structure definitions can > be found in the header files in sys/geom. The backup command itself I missed the header files in sys/geom. The rest I have had found. > can be found in sbin/geom/class/part/geom_part.c. > > > > > > > If you like you can try to fit the first five partitions first and > > > then worry about the last one later. If da1 is an intact disc then > > > running the following piped command should reset all but the last > > > partiton on da0: > > > > > > # gpart backup da1 | sed \$d | gpart restore da0 > > > > > > Try fscking and mounting the first five partitions and see how > > > you get on. Hopefully they'll just work. > > > > > The hopefully is the point why I would like to do it by hand. I do > > not think that there is a huge secret behind. It is just that I did > > not find the documentation. Or doesn't it exist? > > It depends on what you mean by documentation I suppose. Quite a lot of > the GEOM API is documented to varying levels (something I intend to > improve as my time allows). You can look at the sys/sys/diskmbr.h > header file for some useful information though. The MBR format is > documented on Wikipedia. > I noticed that in FreeBSD data structures are hardly documented. When I was still programming, the first step during development was the documentation of the data structures. I kept this documentation in the header files. I must also say that I was massively influenced by Modula-2 and its creators. > > > > > > > disc, you could reconstruct things that way. What does > > > > > > > `gpart show' look like at the moment? > > > > > > > > > > > > It does not come that far > > > > > > > > > > > > gpart list da0 > > > > > > gpart: No such geom: da0. > > > > > > > > > > > > is all I get. > > > > > > > > > > > > My luck is that I have three disks which are the type but > > > > > > manufactured with some months between. But their sizes > > > > > > differ a bit. I think that I should be able to recover much > > > > > > by just comparing the entries. > > > > > > > > > > > > > > > > You can try looking at diskinfo -v da0 to see the numbers. > > > > > > > > > 512 # sectorsize > > > > 500107860480 # mediasize in bytes (466G) > > > > 976773165 # mediasize in sectors > > > > 0 # stripesize > > > > 0 # stripeoffset > > > > 60801 # Cylinders according to firmware. > > > > 255 # Heads according to firmware. > > > > 63 # Sectors according to firmware. > > > > 0000000000006121 # Disk ident. > > > > > > > > One other disk shows the same data while the third one shows > > > > this: > > > > > > > > 512 # sectorsize > > > > 500107862016 # mediasize in bytes (466G) > > > > 976773168 # mediasize in sectors > > > > 4096 # stripesize > > > > 0 # stripeoffset > > > > 15504336 # Cylinders according to firmware. > > > > 1 # Heads according to firmware. > > > > 63 # Sectors according to firmware. > > > > TF0504YS02ZPBP # Disk ident. > > > > > > > > > > These look really different. Are you using other GEOM classes? > > > What else is different about these discs? > > > > The media size is already different. The drives are all Hitachi's > > with 4k sectors. They should be all from the same factory but > > obviously there is a difference. > > > > Ok, good luck. Thank you. Erich