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

Nikola Lečić nikola.lecic at anthesphoria.net
Tue Dec 18 19:40:05 PST 2007


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.

> 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.

> 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.

> 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ć :: Никола Лечић


More information about the freebsd-questions mailing list