Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 May 2005 10:37:26 +0300 (EEST)
From:      BigBrother-{BigB3} <bigbrother@bonbon.net>
To:        freebsd-questions@freebsd.org
Subject:   Re: I used "boot0cfg" and destroyed the MBR.All labels dissapear! (How I Fixed it)
Message-ID:  <20050504100407.T575@bigb3server.bbcluster.gr>

next in thread | raw e-mail | index | archive | help

Hi,

I managed to fix the error of all slices being destroyed. My system is up 
and running. i did not reinstall any programs, just edited the partition 
table and the labels. It took me 3 days to figure out the exact values, so 
I post here my findings, in case somebody faces the same problem.

The problem was solved using two programs from the fixit disk: fdisk and 
disklabel. Note that I am using a whole disc dedicated to freebsd. no 
other partitions exist.

This is a short guide of how to fix it:

a) boot the computer using the floppy disks and enter the Fixit menu with 
the fixit disc inserted.

b) go to menu Configure->Fdisk and delete all partitions (NOTE: I am 
using all the disc dedicated to freebsd. No other OS exist. On your 
situation this may vary).

c) On this screen then I pressed [A] - use Entire disc and saw the new 
automatically calculated sector values (and the offset).

d) I pressed CTRL+C to abort this screen. Only the numbers interested me.

e) i went to menu and pressed the fixit prompt. I went to fixit prompt.

( I run 'disklabel ad0' and 'disklabel -r ad0' and I noted down some 
numbers of the fake partitions. Especially I noted the size (in sectors) 
of it....If this process fails, then you have to repeat the disklabel step 
after every fdisk commans that follows. Also note the number of 
fsize,bsize, and bps/cpg).


f) I edited the partition table using fdisk.
fdisk -u ad0   (ad0 is my first disc)

I deleted all (fake) partitions and created one accoring to the numbers 
that I have extracted from the previous screen. The type was 165 Freebsd.
Thus I have created a big slice ad0s1.

I edited the slice ad0s1 because I saw that there is a hidden parition on 
every freebsd system with thse values:

fdisk ad0s1
Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
<UNUSED>
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
sysid 165,(FreeBSD/NetBSD/386BSD)
     start 0, size 50000 (24 Meg), flag 80 (active)
         beg: cyl 0/ head 0/ sector 1;
         end: cyl 1023/ head 255/ sector 63



I do not know why, but every freebsd system (on my possesion) has a 
partition 4 on slice 1 with these values.


I then edit the labels on that slice using

disklabel -e ad0s1

If that operation fails then you have to install a fresh disklabel using
disklabel -w ad0s1 auto

or

disklabel -w ad0 auto



I edit the labels of that slice. The sectors off-set was known from a 
previous step where I had extracted them using disklabel. The offset is 
calulated by adding the sectors until know. The fsize and other numbers 
are known from the previous step also.


Then you edit the label and write the first line of

a: <sectors size> offset=0 4.2BSD fsize bsize bps/cpg

On the b label put in the offset the sectors size of the previous ( a 
slice) and repeat the process.

Note that the label 'c' correspongs to whole disc so this value shoule 
have size from offset 0 until size the number of disklabel: [sectors/unit: 
XXXXX]. The lats label starts from the sum of all the previous labels 
until the number of sectors/units.

Thus if the calulcated offset it 100 and sectors/unit is 300, then the 
last label will have size 200 and offset 100.

After editing the label, try to mount. Note that the /mnt2/ holds the 
devices for mounting labels.


try to:
mount /mnt2/dev/ad0s1a /mnt

if this succeeds then label a has correct values. If not try to edit 
disklabel with oteher numbers. Remember that as long as you do no issue
[newfs] the inode table is somewhere hidden on the disc and you just have 
to figure out the label information (where it starts and where it ends for 
every slice).

Finally, install bootblocks using

fdisk -B ad0
fdisk -B ad0s1

disklabel -B ad0 auto
disklabel -B ad0s1 auto

and to be 100% sure enter sysinstall and go to fdisk menu and press Q 
quit. it will then ask you to install a boot manager...Say yes to it and 
your PC is 100% ready!

Reboot and enjoy:)



it took me 3 days to figure out this process but I managed to succeed in 
it.

Of course the best advice is (in order to avoid this) to print the 
partitoin information for your hard disc so you know before hand all the 
values...

Just issue (in case you have a ad0 disc)

fdisk ad0  [depending on your disc]
fdisk ad0s1 [-<<-]
disklabel ad0
disklabel ad0s1



i hope that you will not need my short guide on fixing such kind of 
problems, but your never know :)


BB


---
Dreams have no limits!



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