Re: How to recover a damaged partition
Quoting Kevin O'Gorman (kogorman@gmail.com):
> I'm working with new 4TB drives, and one of them just had a bad spot in a
> fairly awkward place.
> The very first block of an ext4 partition was unreadable, and caused problems
> in booting, as well as anything else that wanted to scan partitions.
>
> I overwrote the first 4K with zeroes, deleted the partition (with gdisk) and
> created a new unformatted partition to cover the area. Now that partition
> passes a read test, and I'm checking the other partitions.
>
> The damaged partition has been inactive for a while, so I'm quite sure I have
> adequate backups. But now seems to be a time for me to learn -- lots of things
> have been going wrong, and I've been learning how to cope.
>
> So I wonder if there's a way to get that partition back, at least in part,
> without using my backups.
Having had a similar problem where the first few blocks of a partition
wouldn't read, I used dd to ascertain what I could and couldn't read,
and then:
Create a blank start of a file:
dd bs=512 if=/dev/zero of=/ylarge/image-of-hdd4-skipping-16 count=16
Add the undamaged part of the partition:
dd bs=512 if=/dev/hdd4 of=/ylarge/image-of-hdd4-skipping-16 skip=16 seek=16
See if it can be mended:
e2fsck -n -f /ylarge/image-of-hdd4-skipping-16
If so, mend it:
e2fsck -f /ylarge/image-of-hdd4-skipping-16
Mount it:
mount -t ext3 -o ro,loop=/dev/loop0 /ylarge/image-of-hdd4-skipping-16 /mnt
Copy off all the files.
hdd4 was the failed partition. /ylarge was a filesystem big enough to
hold an image of hdd4. Note however that hdd4 was ext3, not ext4. I
don't know whether that affects things. Good luck.
Cheers,
David.
Reply to: