How To: Recover that ext4 drive that Windows killed

jedi

So if you've ever had to attach an ext4 drive to windows and then install (on windows) a tool for it to read, or "GASP", write to that ext4 drive, good luck with the data on it next time you boot it in Linux.  Turns out that every time Windows boots it screws with the 'superblock' on the hdd.  Even though it doesn't recognize the ext2, ext3, or ext4 formats.  This totally confuses the 'you know what' out of Linux.  (everything Winders does confuses Linux)

Here's hopefully, a fix for that drive and getting your data back.  This is all done via terminal, and all the things you need are "OBVIOUSLY" already installed on VSIDO.

At any point in this process if it asks you if you want to repair something, which it undoubtedly will, you'll want to say yes.  I've done this procedure several times, and never regretted it.  Besides if you are following this 'howto' then something terrible has already happened to the drive right?  So good luck and no warranties with this.

So open terminal, and to determine partition/drive names type the following;

sudo fdisk -l

This will give you the names you need for next.  Still in the same terminal, you'll need to find out if it is the 'superblock' that is the issue so you need to do an 'fsck' on that drive.  Heres how:

sudo fsck.ext4 -v /dev/sda

That represents my hdd on my machine.  Yours may be and probably will be different.  Just be sure you have the correct /dev/xxx for your particular drive.  This will take a few minutes.  My 1TB internal storage drive takes less than 5 minutes to complete this start to finish.

If the 'superblock' is indeed the culprit you can restore a previous 'superblock' backup.  In the same terminal, type the following to find your 'superblock' backups and accomplish this:

sudo mke2fs -n /dev/sda

This command gives you a list of the backed up 'superblocks' on the bad drive.  Choose one from the beginning of the list is my general rule of thumb.  It may even recommend which to choose.  Safe to pick the choice it offers you, if indeed it does give you a choice.  To restore the backed up 'superblock' type the following in the terminal;

Remember, throughout this process you may have to decide whether you want to say (Y) to a repair question.  I've never regretted it.  Matter of fact, if you get tired of typing in (Y) for yes every time, you can also type (A) and it will do all the repairs without questioning you for each one.

(replace 'block-number-here' in the command below with the block number recommended to you by the program or a block number of your choosing from the list provided by the command above)

sudo e2fsck -b block-number-here /dev/sda

Reboot and enjoy your recovered drive.
Forum Netiquette

"No matter how smart you are you can never convince someone stupid that they are stupid."  Anonymous

VastOne

#1
Incredibly well done Jedi.. thank you!

This is an instant classic!

8) 8) 8)

VSIDO      VSIDO Change Blog    

    I dev VSIDO