How to reinstall macOS after hard drive is wiped

In case you wiped your Mac’s hard disk or erased it’s partition map (like me), don’t panic.

The bad news is if you don’t have your data backed up before, you probably lost them all already (Unless you pay professional data recovery company to help you salvage them). However, the good news is, you can have a fresh macOS on your machine soon.

1. Download the macOS installer

If you search online, you will probably find a bunch of guides that tell you to grab the full macOS installer from AppStore. This only works if you have a working Mac that still run a older version of the macOS version you want to install. For example, if you want to install High Sierra (10.13), you need a mac that’s running on Sierra (10.12). Which I wasn’t, and probably you aren’t.

So to get the macOS installer, your best chance is to torrent it from some torrent site. Of course, depending on where you live and the laws, it might be illegal to do so. So I can’t help you more here but it shouldn’t be hard if you have the right keywords to search.

2. Create bootable installer for macOS

You can follow this official guide from apple, it’s very informative and covers all the cases:

3. Mounting the missing hard disk

With all those task done, plug in your bootable USB into your Mac and power it up. Your mac should load the recovery utility in the USB without any keyboard press because your hard disk is wiped.

In the recovery utility, select Disk Utility. You want to make sure your disk0 which is your hard disk is listed. It’s should be at least 500GB for most iMac. It’s definitely not the 32 GB or even smaller drive, that’s your bootable installer USB. If you can see it in Disk Utility, go to the next step. If not, read on.

If it is not visible, which is possible because we wiped it, you need to fire up Terminal. You can do so by going to the menu bar at the top of the screen > Utilities > Terminal. Then type the command:

diskutil list

If you can see disk0 listed in the output, you can mount it by entering the following command:

diskutil mountDisk 0

This should do the job and you can verify by quitting terminal and go back to DiskUtility.

If you cannot mount the drive or the drive is simply not listed in diskutil list, then you probably have a hardware issue and hardware replacement is needed.

4. Erase the hard disk

Since we are doing a fresh installation, we need to erase the disk and start new. Yes, you will lose 100% of your data after this step.

You can do this using Disk Utility. Make double, triple sure that you selected your disk0 on the left sidebar. Click “Erase” at the top. Name it “Macintosh HD” and select APFS for the format option. Finally click Erase and this will reformat the hard disk.

You can quit the Disk Utility app after it’s done formatting.

5. Install macOS

Click Install macOS in the recovery menu.

Depending on how you got your macOS installation image, you might get the error “This copy on the Install macOS High application is damaged and can’t be used to install macOS” or similar.

This is because there is a certificate/signature of Apple contained inside the installer, and it is out of date compare to our Mac’s date.

We can by pass this by firing up Terminal once again, then type the following:

date 121501012018

The format of the date [mm][dd][HH][MM][yyyy]. This will overwrite the date of your machine.

Depending on the installer you are using, the date above may not work. If this happens, just change the date again and try the “Install macOS” option in the recovery menu again.

If you successfully get to the installation location selection screen, make sure you have the newly formatted hard disk selected, not the USB.

Then just follow the installer instruction to finish your installation.

Good luck and enjoy your new Mac!


Mac Yosemite MySQL Unable to Start Reason 255

This problem have took me over 5 hours to fix. So if you are having the same trouble, hope this can help you.

The problem

This problem might happen to you after you install the java patch from apple, updated java, or updated Yosemite 10.10.3 (I did all these). The problem is after the restart, MySQL will not longer start, even if you go to the preference pane and manually click on “Start MySQL Server”. MySQL will give you the error:

    Could not startup MySQL server
    Reason 255

The Process

I tried to reinstall MySQL. I downloaded multiple MySQL dmg from version 5.6.19 to 5.6.23. Why? Because their installers are very weird, the dmg for Mac OS X 10.9 and Mac OS X 10.8 are the same. I thought the guy uploaded the files must have made an error. But they end up being the same dmg since I don’t know when. However, reinstalling did not solve the problem.

After hours of trying, I gave up on the searching for a right dmg (it turns out that the problem has nothing to do with the dmg). So I tried using homebrew to install MySQL. The result was not different, but it gave me some hints about the problem.

    /usr/local/Cellar/mysql/5.6.22/bin/mysql_install_db --verbose --user=Johnson
    2015-02-12 09:34:46 1137 [ERROR] Aborting

    2015-02-12 09:34:46 1137 [Note] Binlog end
    2015-02-12 09:34:46 1137 [Note] /usr/local/Cellar/mysql/5.6.22/bin/mysqld: Shutdown complete

    Warning: The post-install step did not complete successfully
    You can try again using `brew postinstall mysql`

The cause of the problem should related to post install, when MySQL tries to set up the database. So I go ahead and ran the command brew postinstall mysql, which gave me this result:

    ==> /usr/local/Cellar/mysql/5.6.22/bin/mysql_install_db --verbose --user=Johnson
    2015-02-12 09:34:56 1184 [ERROR] Aborting

    2015-02-12 09:34:56 1184 [Note] Binlog end
    2015-02-12 09:34:56 1184 [Note] /usr/local/Cellar/mysql/5.6.22/bin/mysqld: Shutdown complete


    These open issues may also help:
    mysql-connector-c++ cannot build with mariadb  (
    mysql failed to build on 10.10 (
    Packages with --with-mysql option not satisfied by mariadb (

It gave me a few links, all of those didn’t help much. So I tried brew doctor, and it gave me this:

    mktemp: mkdtemp failed on /tmp/homebrew-brew-doctor-crXjPb: Permission denied
    Error: No such file or directory - 

A permission denied! Which some post on the internet suspect that failure of mysql_install_db script might be related to permission issue.

The Solution

I go ahead and set /tmp to 777 (I am reckless), then brew postinstall mysql, and BAM! Problem solved.

Out of curiosity, I uninstalled MySQL in brew, and tried reinstalling it using the most update dmg, and it worked as well.

But now, another problem, what permission should the /tmp folder have? Running Permission Verify with Disk Utility gave me:

    Permissions differ on “tmp”; should be lrwxr-xr-x ; they are drwxrwxrwx

But that default permission is what caused the problem…let’s find out next time.

Edit: Follow Up

If I run Disk Utility on my machine, it actually changes my \tmp folder permission by providing the follow description:

    Permissions differ on “tmp”; should be lrwxr-xr-x ; they are drwxrwxrwt .

This is abnormal. I did some search and found this question on StackOverflow-SuperUser, which the person asking the question also has an abnormal machine like mine.

The cause of this problem is still unclear. The temporary fix to this problem is:

    >sudo chmod 1777 /tmp
    >sudo chmod 1777 /private/tmp

Where the extra 1 is the sticky bit. It will make the directory more secure by forbidding users to delete other user’s file, but still letting everyone to access the directory.