help for a wounded disk drive...

Jerry McAllister jerrymc at msu.edu
Fri Mar 21 13:50:24 PDT 2008


On Fri, Mar 21, 2008 at 01:39:50PM -0400, William Bulley wrote:

> I damaged a Seagate 80 GB EIDE drive that was attached to a FreeBSD 5.4
> system (as ufs) some time ago, and I would like to recover the data on
> this drive - if that is possible.  All positive suggestions are welcome.
> 
> The drive is mechanically and electrically good.  I just can't mount it
> and use it under FreeBSD.  It was a dual boot drive with a DOS partition
> on the first partition and FreeBSD 5.4 on partition two.  I did the normal
> sysinstall for FreeBSD 5.5 as I had done many times before.  Unfortunately,
> I had the older, FreeBSD 5.4 drive cabled up (and powered up) on the second
> IDE channel (using cable select) of an i386 motherboard while I did the 5.5
> install on a new, blank drive on the first IDE channel.
> 
> I told sysinstall to add the standard FreeBSD bootloader on the new drive.
> I don't recall if I allowed for a DOS partition or just used the entire disk.
> The FreeBSD 5.4 disk on the second IDE channel also had the standard FreeBSD
> bootloader from my earlier sysinstall of 5.4 on that disk.
> 
> When I completed the install, I figured I could just mount the second (older)
> drive manually.  When I tried to do this, things went from bad to worse, and
> the new system could never recognize the drive.  I believe the installation
> process attempted to (or succeeded in) putting (an unnecessary) bootloader on
> the older drive.  Had it not been connected, it would probably be okay today.
> I learned an important lesson at that time...
> 
> I don't know what steps to take to recover this drive so I can mount it in a
> read-only mode.  I just want to recover the files on this drive.  It is very
> small by today's standards, so I will likely not use the drive in production.
> 
> I am comfortable running any required shell commands (as root), but I don't
> want to damage the disk drive any further.  I hope I don't have to resort to
> using dd(1) on the raw device!  Thanks in advance for any pointers.

Depends a little on what actually happened to it.   If you just smotched
the boot sector, it should be recoverable as a data disk.  

First, you need to find out as much as you can about the condition of the
disk.  For that, you will need to run  fdisk(8)  and then maybe bsdlabel(8)
to get information.

Presuming the system recognizes the drive as /dev/ad1
do:  
    fdisk ad1

Look at what it tells you.   Most of it is just boilerplace verbiage, but
mixed in there should be some valuable information.   What you want to
find is how many slices are actually configured.   There can be up
to 4, numberes 1..4   If a slice is being used, it should have 
information about it, including size in sectors, what type, if it 
is bootable and if it is marked active for booting.   

Ignore the cylinders/tracks/sectors stuff.  Just look at the slice 
size in sectors/blocks.  The type will tell you if it is FreeBSD
formatted slice or Messy Dos.   FreeBSD is type 165 if I remember 
correctly.

If you can get this kind of information, then there should be enough
left to get more with bsdlabel and possibly even read data.  I don't
remember how far back FreeBSD switched from disklabel to bsdlabel.  They 
are functionally the same, so use whichever your FreeBSD version has.

If you find, for example a slice 2 that appears to be a FreeBSD slice,
then run bsdlabel as: 
    baslabel ad1s2
and pay attention to how it is divided up into partitions in the table.
Ignore all the disk identifier stuff above that.  Just pay attention
to the stuff below the line that says '8 partitions'  where it
names a partition and gives size and offset.

If that gives some decent information, such as a partition 'a' with
some reasonable looking size and (hopefully) an offset of 0 and
maybe some other reasonable looking partitions and offsets (do not
muck with partitin c), then try running fsck on the partitions
you find.

    fsck /dev/ad1s2a       for example.

It should come up with some complaints, but be able to fix them.

If so, create a mount point - something like:
    mkdir /rootfix     or whatever
and try to mount it
    mount /dev/ad1s2a /rootfix

If, after the fsck, this works, cd to it and look around.

Then try this for any other slices+partitions you find that
claim to be FreeBSD type.

If this doesn't work, then you are in for a more difficult task.

////jerry    
   


> 
> Regards,
> 
> web...
> 
> --
> William Bulley                     Email: web at umich.edu
> 
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"


More information about the freebsd-questions mailing list