I accidentally deleted the partition table under Windows through Magic Parted, so I installed Ubuntu on the first 40GB of my hard drive (which I think consist only of windows system files). Is there a way I recover the data on the rest of the hard drive? The drive was formatted, but not thoroughly (no null bytes overwriting), so the data should still be there. Any help is greatly appreciated. Thanks!
You are likely to have lost a lot of files because you have overwritten much of the drive (40Gig is a lot).
First you'll need to create a partition on the rest of the device, but don't put a file system on it. This is easily done in the "Disks" utility.
Then do the following to see a list of files you can recover:
sudo ntfsundelete <device>
Then use things like the following to recover all jpgs:
sudo ntfsundelete <device> -u -m *.jpg
or the following to retrieve a file by inode (the first column in the output of the first command):
sudo ntfsundelete <device> -u -i 99999
Note I haven't tested this as I don't have such data to retrieve.
I've had to recover files from inaccessible partitions, or that have been deleted, on a number of occasions and have always found Testdisk and Photorec to be invaluable and reliable. This is the main website for them http://www.cgsecurity.org/wiki/TestDisk but I installed using the Software Centre. The interface is text-based and keyboard driven but the documentation is very good and gives a practical example you can follow through for your own disk. I'd be pretty hopeful of recovering files from the unused part of the disk with Testdisk and would also think it worth trying to recover files from the overwritten part of the disk with Photorec (despite its name it won't just recover photos, though it was developed for that). Good luck!