On Wed, Mar 26, 2003 at 01:03:03AM +0800, af asdf wrote:
> 
> Anyone knows how to repair disk when the freebsddisk lable is destroyed?
> 
> I have a 12G HD, the 1st partition is Windows NT, the second the for 
> FreeBSD. For some reason i installed a new disk label to it and newfs it a 
> bit. Once I found the newfs started, I have turned power off right away, 
> but the disk is bad now. anyone knows how to repair this?
> 
Yes.  Read the attached.


Cheers,
-- 
Ruslan Ermilov          Sysadmin and DBA,
[EMAIL PROTECTED]               Sunbay Software AG,
[EMAIL PROTECTED]               FreeBSD committer,
+380.652.512.251        Simferopol, Ukraine

http://www.FreeBSD.org  The Power To Serve
http://www.oracle.com   Enabling The Information Age
--- Begin Message ---
Hi!

I have my disk set in a so-called dangerously-dedicated mode,
and its disklabel looks like this:

8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:  8388608   262144    4.2BSD     1024  8192    16   # (Cyl.  260*- 8582*)
  b:   262144        0      swap                        # (Cyl.    0 - 260*)
  c: 19932192        0    unused        0     0         # (Cyl.    0 - 19773)
  d: 11281440  8650752    4.2BSD     1024  8192    16   # (Cyl. 8582*- 19773*)

I recently upgraded the amount of RAM available on this machine
from 128M to 256M, and it took me a while to figure out why
swapon(8) no longer wants to enable swapping on `b' (which is
only 128M large).  I was pretty tired at the moment, and I thought
that maybe the problem is with the contents of my `b' partition,
so I did: dd if=/dev/zero of=/dev/ad0b bs=512 count=1000.  This
did not help, and eventually I recalled the fact of upgrading RAM,
and I've looked into some /sys/kern code to verify my guesses.
Nevertheless, I continued with my work on this machine, and compiled
and installed the new kernel (without any problems) on it.  Next
reboot refused to boot FreeBSD by mentioning that "No operating
system was found".  I wondered how I managed to screw my disk up.
It was too late in the night, so I delayed it until the next morning.
The night and next morning gave me the knowledge about what I did
wrong, and it surprised me a lot, as I never thought about it before.
The disklabel occupies the first sectors of the disk (or slice, if
you are under i386 and have your disk sliced).  My `b' partition
starts from the very first sector of my disk, so when I did the
dd(1) it overwrote the disklabel of my disk with zeroes.  Once
I understood and verified it, I recovered from this very fast.
I remembered that my swap partition was first and exactly 128M
large, so I skipped over this space, and saved some amount of
my `a' partition into a plain file.  Fortunately, file(1) is
smart enough to read the superblock and tell you about the
size of the filesystems.  This way I found the size of my
`a' partition and an offset for my `d' partition.  Hope this
technique could help someone in a similar situation.  Now the
question.  Where is the code in the kernel that prevents swapping
and/or writing to a disklabel portion of a physically first
partition on the disk?


Thanks,
-- 
Ruslan Ermilov          Sysadmin and DBA,
[EMAIL PROTECTED]               Sunbay Software AG,
[EMAIL PROTECTED]               FreeBSD committer,
+380.652.512.251        Simferopol, Ukraine

http://www.FreeBSD.org  The Power To Serve
http://www.oracle.com   Enabling The Information Age

Attachment: pgp00000.pgp
Description: PGP signature


--- End Message ---

Attachment: pgp00001.pgp
Description: PGP signature

Reply via email to