Port-amiga archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Reading bad disk
On Thu, May 01, 2003 at 01:21:26AM +0100, Lars Hecking wrote:
> warning unknown dostype: 0x53575000 marking unused
> warning found rdb->secpercyl(756) != rdb->nsectors(85) * rdb->nheads(9)
> sd3(ahsc0:0:3:0): Check Condition on CDB: 0x08 00 00 00 01 00
> SENSE KEY: Media Error
> ASC/ASCQ: Address Mark Not Found for ID Field
> FRU CODE: 0xe8
> SKSV: Actual Retry Count: 0
>
> sd3: rdb scan I/O error
>
> Does anybody have ideas what I could do? There is no critical data on the
> system, in fact, the configuration of the NetBSD disk is almost identical,
> give or take a few ports/packages. But it would be nice to salvage as much
> as possible.
Make an image of the disk into a file or onto another disk. Do it soon.
Also, use ffs_find (or similar) to find the beginnings of the filesystems.
I got it from the NetBSD mailing list archives, but I don't think it will
hurt to post it again. I made a couple of minor, ugly changes for
Digital UNIX (I blew away my OSF/1 disklabel once). They should be
easy to back out. Also, you may need to compile and run it on OpenBSD
(I had to run it on OSF/1 because the NetBSD compile wouldn't work on
the OSF/1 superblocks).
Someone should make a package. I'd do it but I just got this shiny
new MicroVAX-III that I want to play with, see, and ..... :)
/*
* Copyright (c) 1997 David Brownlee (@mono.org). Licence at end of file.
* Attempt to find ffs filesystems in the event of a lost disklabel.
*
* This program itself will not modify any data on a disk, but using
* disklabel and fsck _can_ cause loss of data - you have been warned!
*
* Compile with 'cc -Wall -O -o ffs_find ffs_find.c'.
*
* To use, run 'ffs_find /dev/rXXNc' (eg rsd0c, rsd1c, or rwd0c etc), note the
* possible filesystems, disklabel appropriately and try to fsck.
* (May want to use /dev/rXXNd on i386).
*
* It reports possible filesystems by checking for two 'superblock like'
* blocks fs.fs_sblkno blocks apart.
*
* Caveats:
* It can find false positives. (It should check more rigorously).
* It assumes 512 byte blocks.
* It assumes the first & second superblocks of a filesystem are intact,
* and at offsets of fs.fs_sblkno and fs.fs_sblkno*2 respectively.
* The 'trick' with sbplus is not particularly palatable,
*
* Comments/suggestions welcome!
*/
#include <stdio.h>
#include <string.h>
#include <sys/param.h>
#if 1
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
#else
#include <ufs/fs.h>
#endif
#define BLOCKSIZE 512
#define SB_SIZE (((sizeof(struct fs)+BLOCKSIZE-1)/BLOCKSIZE)*BLOCKSIZE)
typedef struct
{
struct fs data;
char pad[BLOCKSIZE-1];
}fsplus;
int main(int argc,char **argv)
{
FILE *fds;
fsplus sblock;
int blockno,
size,
last;
if( argc!=2 )
{
fputs("Usage: ffs_find special\n",stderr);
exit(3);
}
if( (fds=fopen(argv[1],"r"))==0 )
{
perror(argv[1]);
exit(3);
}
if( fread(&sblock.data,SB_SIZE,1,fds)==0 )
{
fputs("Unable to read start of partition.\n",stderr);
exit(3);
}
last=0;
do {
if( sblock.data.fs_magic == FS_MAGIC )
{
printf("%d\r",blockno);
fflush(stdout);
if( last && last==blockno-sblock.data.fs_sblkno )
{
size=sblock.data.fs_size*(sblock.data.fs_fsize/BLOCKSIZE);
printf("Possible filesystem at offset %u, size %u (%uMB).\n",
last-sblock.data.fs_sblkno,size,
size/(1024*1024/BLOCKSIZE));
/*
* Do not skip to end of possible filesystem, as may be
* false positive
*/
}
last=blockno;
}
memmove(&sblock.data,(char *)&sblock.data+BLOCKSIZE,
sizeof(sblock.data)-BLOCKSIZE);
++blockno;
}while(fread((char *)&sblock.data+SB_SIZE-BLOCKSIZE,BLOCKSIZE,1,fds));
return(0);
}
/*
* Copyright (c) 1997 David Brownlee (abs@mono.org). All rights reserved.
*
* This program is free software.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
--
Kevin P. Neal http://www.pobox.com/~kpn/
'Concerns about "rights" and "ownership" of domains are inappropriate.
It is appropriate to be concerned about "responsibilities" and "service"
to the community.' -- RFC 1591, page 4: March 1994
Home |
Main Index |
Thread Index |
Old Index