Sample Header Ad - 728x90

How do I actually fix a badly corrupted (but with hardware OK) ext4 system?

2 votes
1 answer
259 views
While creating an install USB disk, I made the trivial error of indicating the wrong device, and ended up overwriting the initial few hundred megabytes of a 230 GB disk. The data was not extremely important, but I would still like to recover what I can. The first, obvious attempt, was `photorec`, which did find some stuff. But then, I hoped I could "fix" what was left of the filesystem (after all, I overwrote less than 0.5%). So I tried to run `e2fsck` with several combinations of parameters, including using a backup superblock (in an analogous way to what is suggested in an answer to a related question ), and I ended up with a bunch of folders in "lost+found" - fair enough. The problem is that some of these folders still give errors such as
ls: cannot access 'lost+found/#26128': Structure needs cleaning
... but if I now run again `e2fsck -f` (as suggested in other answers ), I get nothing strange
e2fsck 1.47.0 (5-Feb-2023)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
EData: 191504/15269888 files (0.1% non-contiguous), 48227460/61049344 blocks
... and by the way, this only takes a couple of seconds, so it is clear that it's not actually check all the content of the disk. I tried to check for other options, and for instance tried `-E discard, but nothing changed: the check is still very quick, and some folders inside lost+found` still give the same errors. How can I fix the errors with those folders that say "Structure needs cleaning"? Note that the device is perfectly working from a hardware point of view.
Asked by Pietro Battiston (123 rep)
Jan 3, 2025, 11:23 PM
Last activity: Jan 4, 2025, 08:32 AM