Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Jun 2010 20:02:58 -0400 (EDT)
From:      Zhengtao Cui <zcui@gmx.com>
To:        Ian Smith <smithi@nimnet.asn.au>
Cc:        Polytropon <freebsd@edvax.de>, freebsd-questions@freebsd.org
Subject:   Re: detached a mounted ufs filesystem
Message-ID:  <alpine.BSF.2.00.1006141958320.1302@qryy.zlubzr.jrfgryy.pbz>
In-Reply-To: <20100614045646.H27982@sola.nimnet.asn.au>
References:  <20100613095242.3DF3110656F6@hub.freebsd.org> <20100614045646.H27982@sola.nimnet.asn.au>

next in thread | previous in thread | raw e-mail | index | archive | help
# 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" <xyin@gmx.com> 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:
> > <UNUSED>
> > The data for partition 3 is:
> > <UNUSED>
> > The data for partition 4 is:
> > <UNUSED>
> >
> > 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.1006141958320.1302>