Trying to recover an ext4 partition from a repartitioned drive

admin 06 May , 2021 0 Comments data recovery

So I had a drive partitioned something like this:

+----------+----------------------+----+--------------+ | P1 | P2 | P3 | ... REST | +----------+----------------------+----+--------------+ 

After partition 3 I think there was one more (probably swap) and some unpartitioned space, but the important one here is partition P3 which was formatted with ext4.

Being convinced I've backed up everything I needed, I've deleted the partition table and created something like this:

+------------------------------------+----------------+ | P1 | P2 | +------------------------------------+----------------+ 

and formatted P1 with ext4 and installed Linux there. I didn't touch the new P2. Of course, for the nth time, I was wrong and I didn't back up everything. Luckily, what I was looking for was a plain text file and I found its content with dd and grep from a live USB. It was located in the current P2, but knowing the size of the old P3, its beginning could be either in the new P1 or P2.

Now, I'm wondering if the entire old P3 could still be untouched. If part of it was at the end of the new P1 when I formatted it, would that have modified it? That's the first big question,

Does formatting a partition with ext4 only write some data at the beginning of it or is the end also modified?

If that didn't touch it, my Linux install probably didn't either because I think I used up less than 10% of P1.

And the second big question,

If the entire P3 is still intact, could I recover it by repeating the search but looking for its magic number, and if so, could I read its size somewhere?

Even if I don't know its exact size, I think I could copy it by estimating its size (say 32 GB, I'm pretty sure it was less than that) and dding it to a larger partition and it should still work, just like it works when you extend your partition and then you have the option to extend your filesystem.

I believe I didn't miss anything other than the file I've managed to recover, but I'm really curious if I could pull this off.

Thanks, any help is appreciated.

submitted by /u/Jamesin_theta
[link] [comments]

Written By admin