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

Snow Mountains snow.mountains.4 at gmail.com
Wed Dec 19 19:58:19 PST 2007

2007/12/19, Nikola Lečić <nikola.lecic at anthesphoria.net>:
> On Wed, 19 Dec 2007 03:54:00 +0100
> "Snow Mountains" <snow.mountains.4 at gmail.com> wrote:
> [...]
> > 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!
> Excellent! Just note that you don't need to calculate offsets; you can
> use asterisk (*) for all offsets from b: (swap) onward; and you can use
> * as the size of the last partition, too.
> > 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?
> Use the value from swapinfo; swap is just that space (unlike sizes that
> you see in df(1) output: they are not sizes of partitions).
> The size of slice: you should anyway _first_ run 'bsdlabel-w /dev/ad1s4'
> -- it will write initial info and the value for c: will be the value
> you should use.

Success!!! After several wrong tables, I got right one, my dear
documents are now visible and readable again! Correct size of swap was
indeed size reported by swapinfo.

> > b. Do I need just bsdlabel -R -e?
> You probably typoed, either '-R' or '-e' (= 'from file' or 'to edit
> directly'). However, I believe you should use '-B' as well, because
> bootstrap code was destroyed too, and you won't be able to boot
> FreeBSD even with recovered partitions.

Indeed (-B), and FreeBSD is bootable again.

> > Is it safe to experiment?
> Yes, it is. If you write wrong data, it will just not work. Once you
> get mountable partitions, please fsck(8) them.

partitions except ad1s4a; I said 'yes' and now it says they are clean.

> > c. What to write as fsize, bsize
> fsize and bsize are 2048 and 16384 if you used all defaults when
> installed FreeBSD (read newfs(8)).
> > 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...
> Hmm, yes... Actually, it seems that they can be calculated by comparing
> data obtained  from 'bsdlabel -A /dev/ad1s4...' (look at the top of the
> output) and from particular 'newfs -N /dev/ad1s4X' (this command doesn't
> create new file system but just prints all data about how it would be
> created) -- but after recovery, of course. Read the entire thread that
> contains this:
>   http://lists.freebsd.org/pipermail/freebsd-questions/2004-January/031603.html
> However, I've never been able to find any info in the docs that exactly
> explains what algorithm newfs(8) uses for this field...
> Therefore I believe (although I'm not 100% sure) that the only way to
> get old bps/cpg data is to
>   (1) dump(8) partitions once they work;
>   (2) "bsdlabel -e" bps/cpg of these partitions to zeros;
>   (3) recreate file systems there (this will write new (true) bps/cpg
>       values);
>   (4) restore(8) filesystems.
> However, if fsck(8) tells you that filesystems are clear once you
> recover them, I believe you don't have to worry about this. Maybe
> some filesystem guru can confirm. (According to this reputable
> source:
>   http://www.onlamp.com/pub/a/bsd/2002/06/27/Big_Scary_Daemons.html
> last three values are actually ignored...)
> --
> Nikola Lečić :: Никола Лечић

I tried to google to find similar partition sizes, and to use their
bsdlabel values, but according to what you said everything depends on
specific disc hardware, so tables of other people are not 100%

But all-zeroes seems to work 100% well and happy!

(And of course, backups are the first thing to do!)

Resume, for archives, what I did in FreeSBIE with your explanations:

o Use disk size reported from raw bsdlabel -w
o Use swap size reported from swapinfo, or guess, but the subtracted
value (disk - sum of other partitions) was not correct for me... :(
o Use partition sizes reported from testdisk
o Assemble table accorting to bsdlabel manual page and to, for
example, dlfind homepage
o Write it with -B option.
o Try to mount; nothing? Play with swap size...
o Mountable? fsck them
o Correct everything fsck wants.
o that's it.

thank you!
Sergi M

More information about the freebsd-questions mailing list