Recovering ext4 partitions.

How to use TestDisk to recover lost partition
Forum rules
When asking for technical support:
- Search for posts on the same topic before posting a new question.
- Give clear, specific information in the title of your post.
- Include as many details as you can, MOST POSTS WILL GET ONLY ONE OR TWO ANSWERS.
- Post a follow up with a "Thank you" or "This worked!"
- When you learn something, use that knowledge to HELP ANOTHER USER LATER.
Before posting, please read
Posts: 1
Joined: 23 Jun 2015, 03:32

Recovering ext4 partitions.

#1 Post by kbtestdisk »

Hello All,

I accidently erased my linux disks and like some help.

What happened:
- I wanted to install Windows 10 preview. Being cautious I backed up the mbr on the Crucial CT500MX200SSD1 SSD.

Code: Select all

dd if=/dev/sda of=mbr.bin bs=446 count=1
- Accidently I picked the wrong disk when I did this:

Code: Select all

diskpart -> select disk 1 -> clean
This wiped out the paritions on the disk
- I immediately powered off, and cloned the SSD.
- I wrote the backed up mbr back to the disk, hoping that would restore the paritions. No luck.

What I tried:
I tried testdisk to see if I could restore the paritions. There are atleast 4 paritions on the disk that I know of:
1)ext4: linux root, 2) linux swap 3) linux ext4 (home, and this is the one I am most interested in) and 4) NTFS.

I started with the Intel partition type, which see the 4 paritions but I get the message that the paritions cannot be recovered. Here are two screen shots:

Then I tried the EFI GPT parition type, which again sees the 4 paritions but I get the same message that they cannot be recovered.

Finally I tried the None type, and this sees the 4 paritions correctly. I can even list files and copy from the larger ext4 partition (but this is encrypted so just copying it does not help).


In the image above, I chiefly want to restore the 3rd listed parition (size 640000000) which is the encrypted home parition.

Some other pertinent information:

Code: Select all

> fdisk -l /dev/sdh
Disk /dev/sdh: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdh doesn't contain a valid partition table

I'll add the testdisk logs soon.
Thanks for the help in advance.


User avatar
Posts: 2835
Joined: 18 Feb 2012, 17:19
Location: Ludwigsburg/Stuttgart - Germany

Re: Recovering ext4 partitions.

#2 Post by Fiona »

5 partitions are listed but Intel-MBR only supports 4 primary partitions or 3 primaries and 1 extended for logical partitions.
If you choose partition table type None, you cannot write a partition into your partition table, that's why you should choose Intel.
On this screen: ... /none1.png
There are 5 partitions listed.
The fourth partition overlaps the third partition and can't be recovered.
Should be set to D for deleted.
The fifth partition fits exactly.
Did you have a try to list your files?
Please let me know!
But the fifth partition starts exactly 1 sector after the third one.
That's why I assume, if you try to set it to L for logical, you can receive the message "structure bad".
In case, you should set it as P for primary only.
Your boot partition should be set to star as primary and active.

Currently it's important, can you list your files on your NTFS parttition?