I made a live USB of ubuntu to install it on my hp pavilion running win 10. Was planning to do dual boot, but accidentally reformatted my main ntfs partition into an ext4. Is there any way I can recover my partition?
You'll probably be better off restoring from a recent backup.
That said, assuming that you didn't change the partition table, it is possible that some files might still be recoverable, by using something like ntfsundelete.
The partition should be considered lost though, as the ext4 formatter has most likely overwritten some of the ntfs metadata/files. You'll have to reinstall windows (which will ask you to reformat the partition) if you want to dual boot.
Is there any way I can recover my partition?
You cannot recover your partition, in the sense that there is no easy way you can get that partition as it was before your accidental formatting. However, depending on the amount of data that was overwritten, you can recover some (or many) of the files contained inside the partition.
To be more precise, you want to recover the contents of the file system. In the case of Windows, it is NTFS. This fact is extremely important, because the strategy you need to use depends on two factors:
- the amount of damaged/overwritten data
- the file system type (NTFS)
Since you installed Ubuntu, I assume you could have overwritten the first 4-5 GB of space on your drive. If this is the case, then you have:
- likely corrupted the integrity of the file system
- overwritten many system file (
C:\WINDOWSand the like)
- probably not overwritten important user files (e.g. your documents)
Normally, with a simply "lost" partition you could use
testdisk and restore it pretty quickly. However, you cannot do that because your file system is corrupted. You need a specialized software which thoroughly analyzes the disk and recovers intact portions of NTFS partitions, reconstructing the directory tree precisely.
Disclaimer: I am the author of RecuperaBit.
There are several programs that claim to recover data from NTFS, however most of the good ones are commercial and Windows-only. RecuperaBit is free software and it rebuilds directory trees very precisely. The following is a comparison table considering four test cases with various kinds of damage, taken from my MSc thesis:
Keep in mind that it currently comes with no GUI and it does not support NTFS compression. Nevertheless, you could use it to recover the sane portions of the file system even if the damage is severe.
I have described how to use the program step-by-step in another answer, in the Software Reccomendations community.