I tried installing Windows to a partition on my Mac but because I'm stupid I accidentally followed an April Fools' tutorial which said that I need to type in clean into diskpart which deleted my whole drive. It wasn't clean all so I hope to recover some data! Please help me.

EDIT: Testdisk has worked. After using it correctly.

ANOTHER EDIT: I have used MacOS Catalina and a 2018 Mac. Sorry for being unclear I was really stressed and worried about my data. :)

  • 1
    Was FileVault enabled? If it was you can probably forget it. Otherwise, see below. Restoring Time Machine to a fully re-formatted drive is your best bet. – Tetsujin Jun 18 '20 at 6:49
  • Nope. But I think a friend of mine had a corrupted, encrypted partition (Encrypted with FileVault) and some experts were still able to save his data – Leocat Jun 18 '20 at 13:31

Don't touch the drive - don't save anything to it, don't create any files on it, don't even open any files on it.

Luckily for you you ran clean on its own, which only wipes the first and last MB of your drive:

On master boot record (MBR) disks, only the MBR partitioning information
and hidden sector information are overwritten. On GUID partition table
(GPT) disks, the GPT partitioning information, including the Protective
MBR, is overwritten. If the ALL parameter is not used, the first 1MB
and the last 1MB of the disk are zeroed. This erases any disk formatting
that had been previously applied to the disk. The disk's state after
cleaning the disk is 'UNINITIALIZED'.

This means that the vast majority of your data is still there, even if you've deleted the partitions that make them visible.

How to use TestDisk to recover your partition

  1. Install testdisk to a bootable USB and run it

  2. Once it's loaded, select your drive (prefer the /dev/rdisk option if it's available)

  3. Confirm that testdisk detected the drive's partition type correctly (more than likely it will be Intel)

  4. Select Analyze

  5. Select Quick search and wait for it to find your partition

  6. If your partition isn't found, select Deeper Search and wait for it to find your partition

  7. Assuming you only had the one Mac partition on the drive, use the arrow keys to toggle the found partition from D (deleted) to * (bootable)

  8. Continue to the next screen and Write the new partition table to the drive

  9. Restart your computer.

If everything worked, you should now be able to boot into your drive as before and your data should be visible as normal.

  • TestDisk can't read APFS. – Tetsujin Jun 18 '20 at 6:48
  • @Tetsujin You're right, but for some reason an overzealous moderator has elected to come along and delete the few comments on this answer indicating that this solution worked for the OP. HFS+ is still pretty common, with APFS only used by post-High Sierra SSDs. Is this why you downvoted this answer? – Hashim Aziz Jun 18 '20 at 8:34
  • Ah, OK - but in that case I'm going to VTC the question as 'unclear' because the whole thing is now left in mid-air. There's an edit saying TestDisk doesn't run, but no information as to Mac or OS. This is just going to confuse future searchers. Not your fault, of course, you were answering based on salient information no longer available. – Tetsujin Jun 18 '20 at 8:38
  • @Tetsujin The OP has now added that information and in any case it's irrelevant because, as mentioned, HFS+ is still the default filesystem for the vast majority of Mac users. For disks that are using APFS, Testdisk detects this and refuses to continue, so this answer also presents no danger whatsoever for that minority. In short, I don't really see any justification for either the downvote or the close vote. – Hashim Aziz Jun 18 '20 at 18:49
  • 'vast majority' .. hardly - anyone on Mojave or newer is forced to use APFS. But mine is a single VTC, not a binding judgement, so it doesn't really matter in the overall scheme of things. The OP's edit saying they're on Catalina makes even less sense. – Tetsujin Jun 18 '20 at 19:04

Lesson nr 1: Don't follow random tutorials from the internet without double-checking with other tutorials to see if they all say the same thing.

Lesson nr 2: Backups exist for a reason.

Repairing the damage (recovering the original partitions) is next to impossible for the average user. The Mac disk could have been setup in various ways and without knowing what the original setup exactly was...
Testdisk should work (using the live environment) but may not be able to recover your partitions. (Again: This depends heavily on on the exact original disk-layout.)

If you have a recent Time Machine backup, boot your Mac from LAN and restore your system. (Which installs a fresh MacOS from the internet and then restores the Time Machine backup.)

If you don't have backup... I hope you learned lessons 1 and 2 for the next time...
You can still easily get your Mac back in working order by doing the re-install thing from a LAN boot, but your personal files are gone.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.