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

Nikola Lečić nikola.lecic at anthesphoria.net
Sun Dec 16 07:50:46 PST 2007


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

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


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


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. :-)
Nikola Lečić :: Никола Лечић

More information about the freebsd-questions mailing list