How to do a clean Lion install

This guide is based on doing a clean Lion install from an existing Lion install (via upgrade). The reason I upgraded first was because I wanted to make sure all important files (such as Mail/keychains etc) that I will be copying over were already Lion-ready. Please note this post is part of the series Clean Lion install for Ruby Development and all info here is followed at your own risk.

What do you need to copy/back up first?

As we’re doing a clean Lion install we’ll be re-installing all our programs from scratch, so the only thing we need (as well as of course the installers for our programs) is a copy of our home directory.

Make sure hidden files are switched on first, in the terminal type:

defaults write AppleShowAllFiles YES

For Yosemite, do:

defaults write AppleShowAllFiles -boolean true ; killall Finder

Then hold down the alt key, right click the finder icon in your dock and select ‘relaunch finder’.

Ideally you want to copy this onto a separate HD, or on a partition of your Time Machine disk (use disk utility to create one if need be). Restoring files from a Time Machine back-up alone can give you ACL and permissions problems – so copying in this manner is a better option, IMO.

Burn Lion installer to DVD

Download Lion from the app store, but quit the installer when it’s ready. Or, if you’ve already downloaded Lion and gone ahead and upgraded, simply go back to the Lion store, hold down alt and click on the ‘purchased’ tab at the top – the faded out ‘installed’ button for Lion will go and you’ll now have the ‘install’ option again, click it, but when it’s ready to install quit the installer.

Go to your applications folder right click on the Install Mac OS X Lion package, and select Show Package Contents. Then go to the /Contents/SharedSupport/ folder and locate the InstallESD.dmg disk image. Open disk utility and drag the disk image into it – then insert a DVD and burn it (make sure verify image is checked).

Clean Lion install

Insert the Lion install disk and restart your Mac, but keep the C key held down and your Mac should boot up from the disk.

Once it’s booted up:

  • Disk utilities > continue
  • Select the disk you want to install Lion on from left hand side
  • Click erase and give it a name
  • If you want to securely delete what’s already on there choose the option in ‘security options’
  • Click ‘erase’
  • Once done close window
  • Back in the main options screen select Reinstall Mac OS X (fresh copy option)

Then follow the instructions to set it up. Use the same account name and password as your previous install – as that makes it easier when copying over your keychain, etc.

Turn on Firewall, install LittleSnitch and turn off wake from sleep for network activity

For some odd reason the Firewall isn’t on by default, so System Prefs > Security and Privacy.
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