From owner-freebsd-current Wed Aug 26 13:54:34 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA15856 for freebsd-current-outgoing; Wed, 26 Aug 1998 13:54:34 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from tim.xenologics.com (tim.xenologics.com [194.77.5.24]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA15798 for ; Wed, 26 Aug 1998 13:54:19 -0700 (PDT) (envelope-from seggers@semyam.dinoco.de) Received: (from uucp@localhost) by tim.xenologics.com (8.8.5/8.8.8) with UUCP id WAA16782; Wed, 26 Aug 1998 22:47:49 +0200 (MET DST) Received: from semyam.dinoco.de (semyam.dinoco.de [127.0.0.1]) by semyam.dinoco.de (8.9.1/8.8.8) with ESMTP id WAA26730; Wed, 26 Aug 1998 22:46:15 +0200 (CEST) (envelope-from seggers@semyam.dinoco.de) Message-Id: <199808262046.WAA26730@semyam.dinoco.de> To: Mikhail Teterin cc: seggers@semyam.dinoco.de (Stefan Eggers), current@FreeBSD.ORG Subject: Re: recovering disk In-reply-to: Your message of "Wed, 26 Aug 1998 15:22:37 EDT." <199808261922.PAA16299@xxx.video-collage.com> Date: Wed, 26 Aug 1998 22:46:15 +0200 From: Stefan Eggers Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG [Now the questions is how often this happens. Would it be worth to make an additional disklabel and - for systems having it - fdisk partition table recovery tool? How's the opinion on this?] > So, the first backup superblock is right next to the main one? Right. That's at least what I saw all the time when I used newfs. The main one is at sector 16 and the first alternative superblock ended up beging at sector 32. With default parameters the next one was 65536 sectors away but that changed with different parameters. I don't know how this gets calculated and would have to look at the code. > Ok. The disk was mounted at the time of the crash. Would not the > super blocks differ? The magic number is in the right place and the parameters are of course the same. What differs is the clean flag and maybe some other unimportant data. > So, how did you get it back? The start was clear from the two superblocks occuring in succession. The field fs_size in the superblock told me how large it was. That was fortunately all I needed. My alternative plan for recovery (in case the superblocks were not that clearly marking the filesystem start because the were over- written) was to take the distance between two cylinder group blocks (see /usr/include/ufs/ffs/fs.h) and the ordinal number of the blocks to calculate where cylinder group 0 would start, subtract from that two times the size of the superblocks and an additional 8 KByte which are reserved for the disklabel and don't get used by the FFS file- system code. Both I did with reading 8 KByte blocks and advancing 8 KByte. For other block sizes one will probably have to reduce it. I checked the magic numbers for the block and if it like either one extracted the information I needed. For the superblocks I choose fs_size and for the cylinder group blocks cg_cgx which is their ordinal number starting from 0 for the first one as far as I remem- ber. > Yes... Still, any chance I can re-create the partition table (with > fdisk) and disklabel? Once you found your filesystems you are probably able which ones were in the same disklabel. That's the disklabel. And as there is one disklabel per fdisk partition a little thinking should get you to the values for fdisk. I won't write it here as I most likely will get it wrong (it's nearly 11:00 p.m. here). The CHS information in the fdisk partition table is hard to get right by hand but I think fdisk can calculate them once you give it the correct BIOS geometry. As far as I know this is only used in the BIOS to locate the partition's boot block. Stefan. -- Stefan Eggers Lu4 yao2 zhi1 ma3 li4, Max-Slevogt-Str. 1 ri4 jiu3 jian4 ren2 xin1. 51109 Koeln Federal Republic of Germany To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message