Lost FreeBSD slices (labels?) after NetBSD install -- please help!!

Snow Mountains snow.mountains.4 at gmail.com
Tue Dec 18 18:54:03 PST 2007


2007/12/16, Nikola Lečić <nikola.lecic at anthesphoria.net>:
> Hello,
>
> On Fri, 14 Dec 2007 05:15:16 +0000
> "Snow Mountains" <snow.mountains.4 at gmail.com> wrote:
>
> > People, I have FreeBSD install on 80G disk that looked like this:
> >
> > ad1s1 ~ 2.4G
> > ad1s2 ~23.0G
> > ad1s3 ~19.1G
> > ad1s4 ~38.0G, FreeBSD partition, sliced like this:
>                         ^^^^^^^^^  ^^^^^^
>        (a note: the correct terminology is actually the opposite:
>        these a...e are "partitions", real BSD partitions.
>        What is called "partition" in non-BSD world is a slice here;
>        so: "FreeBSD slice, (BSD-)partitioned/labelled like this...")
>
> > ------------------------
> > ad1s4a /     (507630 1K-blocks)
> > ad1s4b swap
> > ad1s4d /var
> > ad1s4e /tmp
> > ad1s4f /usr
> >
> [...]
> > However, FreeBSD is now unbootable!!! Then I loaded FreeSBIE (FreeBSD
> > 6.2 live CD), tried 'boot0cfg -B /dev/ad1' (also with '-d 0x80'), but
> > no help! Then I realized that ad1s4 slices are lost. This means:
> >
> > A) from FreeSBIE, there is only /dev/ad1s4, no a,b,d,e,f. If I do
> > this: FreeSBIE# mount /dev/ad1s4 /mnt/ufs.4
> > this is former / (ad1s4a) and is of its size (~507M).
>
> This probably means that you unwillingly changed FreeBSD label of ad1s4
> and it's most likely that NetBSD wrote its own instead. However, from
> the bsdlabel(8) manpage:
>
>      The various BSDs all use slightly different versions of BSD labels
>      and are not generally compatible.
>
> So, NetBSD didn't recognise FreeBSD's labels and understood entire
> ad1s4 as one partition; however, ad1s4's reality is that it begins with
> small / (lost ad1s4a) and that is what you see; the rest is just
> ignored.
>
> boot0cfg did nothing because NetBSD obviously deleted ad1s4 FreeBSD's
> bootstrap code as well.
>
> > I can't reach other slices! However, it gives me hope that NetBSD's
> > slices are also invisible, although working from within itself:
> > FreeSBIE# mount /dev/ad1s1 /mnt/ufs.1
> > gives also small NetBSD's / (its wd0a), not /usr etc.
>
> The same reason as above.
>
> > [...]
> > Please help me to recover my FreeBSD system. If I lost my data (ok, I
> > understand they are buried, not erased), please tell me that gently.
> > :-(
>
> That's why I think that you haven't lost any data. You must however
> re-create bsdlabel table on ad1s4. Since you didn't mention that you
> have a backup of bsdlabel (do you? :-)), you must recover it.
>
> There are two small utilities designed for this purpose, dlfind and
> ffsrescue:
>
>   http://www.42.org/~sec/resources/disklabel.html
>   http://www.leidinger.net/FreeBSD/ffsrescue.tar.gz
>
> but they don't recognise UFS2 beginning marks (only UFS1 ones).
> However, I tested sysutils/testdisk and it recognised UFS2 labels on my
> healthy slices perfectly, so there is no reason that it can't help
> you, since it simply analyses slice contents. This utility is not part
> of FreeSBIE, but I think that you can just download
>
>   ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6.2-release/sysutils/testdisk-6.3.tbz
>
> Then untar it in ~freesbie and run the binary. Just do this:
>
>   ./testdisk /dev/ad1s4
>
> and choose "non partitioned" in the second menu. Please note that
> testdisk will not recognise your swap. Then please try to compare
> results (given in 512k-blocks) to what you remember about partition
> sizes. If it gives you reasonable proportions, then re-creating a
> bsdlabel shouldn't be a big problem.
>
> So please take these actions and if the aforementioned assumptions are
> correct and you obtain some useful info, we shall continue. :-)

Hello and thanks veeeery much for this response and because you
pointed me to right direction - what to read! It took me some time to
run this and to understand always what I am doing, but it seems to
work!

testdisk gives me sizes that 100% correspond with _partition_ (:))
proportions I remember (and some nonsenses about tiny FAT partition
somewhere...). dlfind homepage was incredibly useful for me as newbie
in creating BSD partition labels, and I created bsdlabel file,
carefully calculated offsets, I am happy that former ad1s4a is
mountable so that I can read /etc/fstab!

However I have several questions just to be 100% sure.

a. swap size: by an accident, I have written swapsize (from swapinfo)
of 1024 1kb blocks; it is slightly different from what I get when I
subtract all partition size from total slice's size (as testdisk
reported). What I should trust?

b. Do I need just bsdlabel -R -e? Is it safe to experiment?

c. What to write as fsize, bsize and bps/cpg? It is completly
confusing for me, bps/cpg explanation from bsdlabel man page is
unclear to me, I see that some people use all zeros and I can not find
a clue in various examples...

Again, many thanks!


More information about the freebsd-questions mailing list