Clean macOS install – the easy way

I’ve always been a fan of doing a clean OS install for every major version as you usually get left with a pristine system that feels almost as good as the first day you bought your machine ?

To simplify things I’ve settled on this new ‘easy’ procedure which should only take a few hours. It does however expect you to have made a note of your passwords (details on how to do this below) and to use iCloud for things like contacts (most of us are iPhone users anyway so probably already doing this).

This guide was last tested on macOS Big Sur 11.2.

What does this guide cover?

  • Backing up your personal files (basically everything in your Home directory)
  • A fresh clean install after wiping your disk 
  • Restoring your files and emails

Before you start

Before you start you will need to make sure your existing computer is running to the same OS version as your target machine (this just makes things easier and ensures your system has updated things like email) so do an upgrade first.

What do you need to copy/back up before you begin?

As we’ll be re-installing all our programs and dev environment from scratch, the only thing we need apart from the installers for our programs, is a copy of our files/data and passwords, and for contacts, calendar and notes to be switched on for iCloud.

For most of us, almost everything we need will be located in our home directory. So for instance on my mine this is Macintosh HD > Users > Aston, making Aston my home directory. Simply drag this folder on to an external hard drive (if you are dragging the contents of it, be sure hidden files are switched on first, which can be done via the following in terminal:

defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder

Just for peace of mind, ensure you have done a Time Machine backup in case something goes seriously wrong (it never has in my case tho).

iCloud

I personally use iCloud for the Notes, Calendar and Contacts apps (as well as for Safari bookmarks) because I have an iPhone and it’s really handy having them automatically synced. If you do the same you won’t need to worry about transferring their data to your new install as they will get synced afterwards. I personally do not use iCloud for passwords, if you don’t either, make sure you have a copy of them…

Make a note of your passwords

For some reason Apple have made it practically impossible to transfer the passwords stored in your ‘local items’ keychain, so now I just make a note of any passwords I need (and put them into a password protected PDF afterwards). Most of the time you can reset app/website passwords by email, so the most important passwords are for your emails.

Passwords will usually be stored in your Keychain app, or Safari. Here’s how to get them:

KEYCHAIN PASSWORDS – simply open the Keychain Access app and then look in the ‘login’ and ‘local items’ sections on the left. To make a note of any passwords stored here simply right-click and select ‘copy password to clipboard’. Then make a note of it. I’d use something like a ‘mypasswords.txt’ file – which you can later convert to a PDF and password protect it.

SAFARI PASSWORDS – Open Safari then go to Preferences > Passwords. You can then click on an item to view the password. Add the ones you need to your ‘my passwords.txt’ file.

Once done, in your text editor (with your password file open) go to Print > Save as PDF > Security Options, and then enter a password and save it 😀

Once everything is backed up

We can now begin install of macOS onto our machine – if you are reinstalling onto your original/only computer double check you have ALL of your files backed up or copied onto an external drive because you will be wiping your computer’s drive clean! To be on the safe side, do a Time Machine backup on to another disk too – I’ve never needed it but it will be there for peace of mind.

Create a bootable installer for macOS

Use this guide to create a bootable installer: https://support.apple.com/en-us/HT201372

Time to install macOS!

Insert the USB drive and restart your Mac, but hold down CMD and R (on older Macs you might need to hold down the ALT key instead)

If you have a newer version of macOS it will ask you to type in the password of an existing account. Then…

  • Go to Disk Utilities
  • From the ‘View’ menu select ‘Show All Devices’
  • Select the disk you want to install macOS on to
  • Select APFS and GUID Partition Map (don’t select encrypted, we’ll do that later)
  • Give it a name (most people use ‘Macintosh HD’)
  • If you want to securely delete what’s already on there choose the option in ‘security options’ (Not needed if your previous install was encrypted)
  • Click ‘erase’
  • Once done close the window
  • Back in the main options screen select Reinstall Mac OS X

Then follow the instructions to set it up. To make life easier I use the same user account name and password as my previous install. Then once it has installed…

Change your account name, turn on Firewall, install LittleSnitch and turn off wake from sleep for network activity

Firstly, DO NOT open the MAIL app until after we have restored all of our mail settings!

  • Apple now prefers to use lowercase for account names but if you’re like me, and prefer to capitalise the first letter of your name go to System Prefs > Users & Groups > click on lock to make changes > right click you user account > Advanced, then from here change location of Home directory (so mine is /Users/Aston) then after it restarts in finder navigate to /Users/yourname and change it to /Users/Yourname.
  • For some odd reason the Firewall isn’t on by default, so go to System Prefs > Security and Privacy to turn it on.
  • Install LittleSnitch if you like to control network activity for your programs.
  • Then if you don’t want your Mac to wake from sleep because of network activity, turn it off via System prefs > energy saver > uncheck wake for network access

Time to put back your files and mail

Now that you’ve backed up all your important files and done a clean install, it’s time to put back all your important stuff such as your emails ,files and other important files such as those in your .ssh folder.

First, make sure hidden files are switched on, in the terminal type:

defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder

Apple Mail

This used to be a pain, thankfully Apple have made things easier, simply copy these (or the contents from them) from your backup to the same places on your new install:

/.Library/Mail
/.Library/Accounts

RESTART YOUR MACHINE

Once your machine has restarted it is ok to open Apple Mail – all your email accounts and emails should be present, however you will be prompted for the passwords.

Hidden files, folders and fonts

Move the /.ssh folder from your backup to the root of your new home folder.

Repeat for any other hidden files you need, such as the .bash_profile and .gemrc etc. (I recommend copying program specific files AFTER you have installed them, such as .gvimrc, .gitconfig, .vim/colors directory, etc.)

Copy or double click any fonts you want installed on your new system, from /.Library/Fonts on your backup to the same on you new install.

Copying over your iPhone/iPad backups

These are located in /.Library/Application Support/MobileSync/Backup/ – copy them to the same location.

Restoring the rest of the home directory and installing your other programs

Now the easy part!

You can now move all your other files from the backup to the new install. Personally if a folder already exists (such as the Music, Movies, Documents, Downloads, Desktop folders etc) I move the contents of the folder into it rather than trying to overwrite it. Your custom/non-standard folders can just be copied over.

Once that’s done, you can then install all your programs as normal.

There you have it, a nice fresh start which should give your machine a new lease of life ?