You have bad media. You need to read the disk sector by sector, save
it elsewhere, write it to another drive, and then try to fsck it --
HOWEVER, DON'T FSCK THE ORIGINAL. Fsck can actually cause serious
damage if it guesses wrong.
The following is a small C program that I just threw together to read
sector by sector and dump the data on stdout. No guarantees
whatsoever:
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#define SECTORSIZE 512
int read_sector(int fd, void *buf)
{
char *p = buf;
int bytes = SECTORSIZE;
int rv;
while ( bytes ) {
if ( (rv = read(fd, p, bytes)) <= 0 ) {
if ( rv < 0 || errno == EINTR )
continue; /* Happens... */
return 0; /* Error */
}
p += rv;
bytes -= rv;
}
return 1; /* Success */
}
int main(int argc, char *argv[])
{
unsigned long long count;
unsigned long long n;
int fd;
char buffer[SECTORSIZE];
if ( argc != 3 ) {
fprintf(stderr, "Usage: %s device sectors\n", argv[0]);
exit(1);
}
count = strtoull(argv[2], NULL, 0);
fd = open(argv[1], O_RDONLY);
if ( fd < 0 ) {
perror(argv[1]);
exit(1);
}
n = 0;
while ( count-- ) {
if ( !read_sector(fd, buffer) ) {
fprintf(stderr, "Sector %llu: %s\n", n, strerror(errno));
memset(buffer, 0, SECTORSIZE);
}
if ( fwrite(buffer, 1, SECTORSIZE, stdout) != SECTORSIZE ) {
fprintf(stderr, "Sector %llu: output error: %s\n", n, strerror(errno));
exit(1);
}
n++;
}
return 0;
}
-hpa
-- <hpa@transmeta.com> at work, <hpa@zytor.com> in private! "Unix gives you enough rope to shoot yourself in the foot." http://www.zytor.com/~hpa/puzzle.txt <amsp@zytor.com> - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/