From owner-freebsd-questions@FreeBSD.ORG Tue Jun 15 00:03:22 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 7A6E31065677 for ; Tue, 15 Jun 2010 00:03:22 +0000 (UTC) (envelope-from zcui@gmx.com) Received: from mailout-us.gmx.com (mailout-us.gmx.com [74.208.5.67]) by mx1.freebsd.org (Postfix) with SMTP id 3714D8FC14 for ; Tue, 15 Jun 2010 00:03:22 +0000 (UTC) Received: (qmail invoked by alias); 15 Jun 2010 00:03:21 -0000 Received: from pool-173-67-1-8.bltmmd.fios.verizon.net (EHLO dell.home) [173.67.1.8] by mail.gmx.com (mp-us002) with SMTP; 14 Jun 2010 20:03:21 -0400 X-Authenticated: #50282390 X-Provags-ID: V01U2FsdGVkX18qeXMKfNYqBSYozjSN2KzGljMMN0kP7itjgTRRkz UAUoXP0XMayMER Date: Mon, 14 Jun 2010 20:02:58 -0400 (EDT) From: Zhengtao Cui To: Ian Smith In-Reply-To: <20100614045646.H27982@sola.nimnet.asn.au> Message-ID: References: <20100613095242.3DF3110656F6@hub.freebsd.org> <20100614045646.H27982@sola.nimnet.asn.au> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Y-GMX-Trusted: 0 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: Tue, 15 Jun 2010 00:03:22 -0000 # bsdlabel /dev/da0s1 says bsdlabel: unable to get correct path for /dev/da0s1: No such file or directory. How do I make a fresh label if I have only 'c' and 'd' partitions? How do I dd the first 126 sectors to a file? Thanks, On Mon, 14 Jun 2010, Ian Smith wrote: > 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