LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   fsck.ext4 zero-filled Files on a lvm-partition because of dying drive (https://www.linuxquestions.org/questions/linux-newbie-8/fsck-ext4-zero-filled-files-on-a-lvm-partition-because-of-dying-drive-4175491917/)

DrBenzo 01-20-2014 10:58 AM

fsck.ext4 zero-filled Files on a lvm-partition because of dying drive
 
Hello,

I did a fsck.ext4 on a unmountet filesystem:
Code:

fsck -yv /dev/data/GrandCentralStation
After this the files had the right size, names and even the right rights and ownerships!

The only problem is, that those files have all been zero-filled by fsck, so they are now useless...

I checked many files with a Hex-Editor and every larger file has only zeros as "data".

So my question is now: Is there some way to "undo" the fsck?

Can i repair the fs by using the journal and backup-superblock (iīm not sure how to this correct right now, either by using fsck options i didnīt read yet, or by using file-carvers like ext4magic, testdisk/photorec, scalpel).

Best Regards

DrBenzo

DrBenzo 01-23-2014 08:26 AM

push

jpollard 01-23-2014 12:06 PM

fsck doesn't "zero-fill". Ever.

What it does is repair pointers to damaged blocks.

What very likely happened is that the damaged blocks could not be read to be relocated by the drive - but fsck forced the pointers to blocks, which were likely already zero filled.

Alternatively (and it depends on the filesystem and driver) fsck didn't zero fill, but left holes in the file for the damaged blocks. Such holes are always filled with null pages in memory when read.

Exactly which scenario occurred can be identified by a file system debugger. Holes in file (also referred to as "sparse file allocations") will be identified by missing metadata pointers. The file size information is stored in the inode, but bad blocks removed by the driver will not be identified.

But there is little chance of recovery from a failing disk.

syg00 01-23-2014 05:00 PM

Quote:

Originally Posted by DrBenzo (Post 5101557)
So my question is now: Is there some way to "undo" the fsck?

Can i repair the fs by using the journal and backup-superblock (iīm not sure how to this correct right now, either by using fsck options i didnīt read yet, or by using file-carvers like ext4magic, testdisk/photorec, scalpel).

Nope.
The journal has already been run, and all the superblocks would have been "cleaned". I've never seen what you describe, but I agree with @jpollard that sparse files looks a good bet - would explain the apparent zero data.

Some of the forensics tools might help, but they are slooooooow, and can (do) result in partial files in extreme situations. fsck is designed to recover the integrity of the filesystem itself - backups are for data.

DrBenzo 01-24-2014 07:19 AM

Quote:

Originally Posted by jpollard (Post 5103795)
fsck doesn't "zero-fill". Ever.

What it does is repair pointers to damaged blocks.

What very likely happened is that the damaged blocks could not be read to be relocated by the drive - but fsck forced the pointers to blocks, which were likely already zero filled.

Alternatively (and it depends on the filesystem and driver) fsck didn't zero fill, but left holes in the file for the damaged blocks. Such holes are always filled with null pages in memory when read.

Exactly which scenario occurred can be identified by a file system debugger. Holes in file (also referred to as "sparse file allocations") will be identified by missing metadata pointers. The file size information is stored in the inode, but bad blocks removed by the driver will not be identified.

But there is little chance of recovery from a failing disk.

Thanks for reply!

There are not only holes in the files, the files are one big "black hole" whithout any data left. Before i ran fsck i could read many of the files without problems. After the fsck run there where ~1TB of empty files, can this be done with what you described?

jpollard 01-24-2014 07:44 AM

A failing disk can result in lots of things.

Very likely that is what is happening.

If you have a head crash, you tend to only have one chance at retrieving data - That is because of damage to the read head causing damage to the disk as it reads... Thus a second read gets nothing.

I was able to recover data ONCE in such a situation - I copied the disk, but in the process scraped off nearly all the oxide from the disk being read. This was a LONG time ago when "removable packs" were cheaper than a whole drive, and drives were the size of washing machines.

My last attempt was a 2TB disk starting to go bad... Didn't get much at all.


All times are GMT -5. The time now is 04:38 PM.