From owner-freebsd-questions@FreeBSD.ORG Sun Jun 13 20:15:05 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 35FBD1065670 for ; Sun, 13 Jun 2010 20:15:05 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from sola.nimnet.asn.au (paqi.nimnet.asn.au [115.70.110.159]) by mx1.freebsd.org (Postfix) with ESMTP id 8C9728FC1E for ; Sun, 13 Jun 2010 20:15:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by sola.nimnet.asn.au (8.14.2/8.14.2) with ESMTP id o5DKErdi055025; Mon, 14 Jun 2010 06:14:53 +1000 (EST) (envelope-from smithi@nimnet.asn.au) Date: Mon, 14 Jun 2010 06:14:52 +1000 (EST) From: Ian Smith To: Xihong Yin In-Reply-To: <20100613095242.3DF3110656F6@hub.freebsd.org> Message-ID: <20100614045646.H27982@sola.nimnet.asn.au> References: <20100613095242.3DF3110656F6@hub.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: Polytropon , freebsd-questions@freebsd.org Subject: Re: detached a mounted ufs filesystem X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jun 2010 20:15:05 -0000 In freebsd-questions Digest, Vol 314, Issue 13, Message: 22 On Sat, 12 Jun 2010 22:38:15 -0400 "Xihong Yin" wrote: > 'fdisk /dev/da0' output is > > ******* Working on device /dev/da0 ******* > parameters extracted from in-core disklabel are: > cylinders=14593 heads=255 sectors/track=63 (16065 blks/cyl) > > Figures below won't work with BIOS for partitions not in cyl 1 > parameters to be used for BIOS calculations are: > cylinders=14593 heads=255 sectors/track=63 (16065 blks/cyl) > > Media sector size is 512 > Warning: BIOS sector numbering starts with sector 1 > Information from DOS bootblock is: > The data for partition 1 is: > sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD) > start 63, size 234436482 (114470 Meg), flag 80 (active) > beg: cyl 0/ head 1/ sector 1; > end: cyl 1023/ head 254/ sector 63 Ok, the DOS partition table looks likely intact; it says you have one slice ad0s1 occupying the entire disk _after_ the first 63 sectors. Checking .. 14593 * 255 * 63 = 234436545 sectors, less DOS partition 1 (FreeBSD s1) = 234436482 sectors equals 63 sectors, being all of cylinder 0, head 0; slices start on cylinder boundaries. > The data for partition 2 is: > > The data for partition 3 is: > > The data for partition 4 is: > > > I tried 'fsck_ufs /dev/da0', it says > > ** /dev/da0 > Cannot find file system superblock > ioctl (GCINFO): Inappropriate ioctl for device > fsck_ufs: /dev/da0: can't read disk label Yes, as it should. You haven't lost your MBR & partition table, but it appears you may have lost the bsdlabel at the beginning of slice 1; this is likely why FreeBSD only finds /dev/da0 and (perhaps) /dev/da0a .. In the absence of a label on slice 1 (listing FreeBSD partitions c, the whole slice, and one or more of a, b, d - h) the system seems to assume this is a 'dangerously dedicated' disk, with no slices, covering the whole disk - but still with no label. I think the system is probably assuming wrongly here, from a missing or damaged label. Polytropon's advice to dd the whole drive to somewhere is excellent if you have 114GB spare somewhere - but if you don't, at least dd the first 126 or so sectors to a file in case of further disasters. > I forget what layout the disk has. Normally I used /dev/da0s1d to mount the disk. > > What the next step should I do? First, to see if there's any meaningful label there, try just: # bsdlabel /dev/da0s1 If that disk just had a single 'd' partition, as sounds maybe likely?, and it doesn't show up with the above command, then you may get away with just making a fresh label for the whole slice, with just 'c' and 'd' partitions, both of size 234436482 sectors. I'm not the best person to advise on the right bsdlabel command, so I won't speculate (possibly mis-advising you) on that. If you had other partitions than just 'd' in that slice then working out the boundaries and sizes will be a lot more complex, but if just one it looks fixable. Of course, if the label at the beginning of slice 1 was clobbered, so may have been other data, but with a new label you might be able to recover it with 'fsck da0s1d' if the filesystem is more or less intact. It's always worth keeping a copy of the output of bsdlabel for every FreeBSD slice somewhere safe (like on paper!) for times such as these. cheers, Ian