Linux – Recovering a file with bad blocks in the middle

ext4linux

A large file on our ext4 file system may have picked up a bad block in the middle. Copying the file to another drive results in an input/output error part way through. Data beyond the bad sectors still seems ok though.

We don't have a backup of this file since it was recently created, so I'm looking for a way of copying the entire readable portion of the file while skipping bad sectors.

I've read other sites which suggest ways of recovering entire hard drives with bad blocks but they don't say much about recovering any files which span the bad blocks.

Thanks.

Best Answer

You should be able to dd it:

dd if=fileWithBadBlocks of=recoveredFile bs=4k conv=noerror,sync
Related Topic