Running out of disk space? Universal Binaries Bloating Your Mac? LIPOsuction is an option!

UPDATE:  If you’re running Mac OS X Lion 10.7 or later, the information in this weblog post does not apply, as Apple removed the Universal Binary capability, “Rosetta”, from this version of Mac OS X and later.  However, if you’re still running 10.6 or earlier, this can still apply, but beware, that some programs, like Adobe’s Flash, does not like to be slimmed down with ‘lipo’.

 

So I bought my iMac a year or two ago, and have absolutely fallen in love with the operating system (as far as loving an operating system can go).  My iMac came with a 650GB hard drive, and I have a 1.5TB external drive attached for my TimeMachine backups.  Believe it or not, disk space is beginning to be a problem, as I only have 35GB free.  I have well over 150GB 200GB of photos (I love my Nikon D80), and at least that much in home video files (vacation, son’s birth, vacation, et cetera) as well as a couple of movies I purchased from iTunes (total of about 20GB).  What to do?!?

I ran into this some time ago, but fixed it, obviously temporarily, by removing unnecessary files.  I event migrated my BootCamp partition to a virtualized machine with VMware Fusion, and then ultimately removed it after I realized that I hadn’t touched any of my Windows programs in over six months.  Minor help, but here I am again.  You know what they say about fad diets, right?

So, if a fad diet isn’t working, what are the options?  Surgical Liposuction?  Or surgical replacement?!

LIPOSUCTION?  REALLY?
So tell me, why would I say liposuction?  Isn’t that a radical (and dated) form of surgery for the obese or barbie-dall ‘wanna-be’s?  We’re talking about a piece of hardware here, aren’t we?

Actually, no.  We’re talking about software and how Apple’s strategy to migrate from the Motorola based PowerPC-based Macs to the newer Intel-based Macs.  The code word for applications that support both base-codes is ‘Universal Binary’.  A ‘Universal Binary’ contains code that is executable on either a PowerPC or Intel Mac– this means it’s essentially a single file that has a branch in it at run time that determines the processor and executes the appropriate code for the system.  Very convenient for Mac users to not have to worry about which platform they own (when the PowerPC was more common).  However, with the fact that Intel-macs are really the only macs that are being developed for, this is getting less and less common though.  Nowadays, you will likely see an application that advertises ‘For Intel Macs only’.  Check the AppStore– you’ll see plenty.  When you see this, it’s a ‘skinny’ app.  If it says ‘Universal’, then it’s a bloated app– it has code that the computer won’t use.  That’s like buying one pair of pants only to notice that it consumes two hangers in your closet, or two spaces in your dresser– how space consuming is that?!?  A LOT!

How to resolve this anachronism?  Have no (some) fear– lipo is here!!  Check the lipo man page for details either on the Apple Developer’s website or your terminal (type ‘man lipo‘ at any Mac OS X terminal prompt).

NOTE:  The Mac OS X supports three different architectures right now– PowerPC, 64-bit Intel and 32-bit intel.  Be sure you choose the right one (or ones) for you!!  If you have ANY DOUBT, DON’T use lipo!  Use of LIPO is at YOUR OWN RISK, and MacOSXDaily.com takes no responsibility for your use, misuse, understanding or misunderstanding of any command referenced on this (or other) website.

Want to check for yourself?  Try finding a Mac OS X application bundle that you believe is BIG and you want to thin.

QUESTION?  You may be asking “What’s a application bundle?”  That’s the directory that usually ends in .app under the /Applications folder and has a standard sub-directory structure that includes [Appname].app/Contents/MacOS).  For more details, you may want to see the Wikipedia article and other references.

Since I download MP3 not only from iTunes but Amazon as well, I have one that’s called Amazon MP3 Downloader (in the terminal, I would reference it with the blank spaces preceded by a backspace– /Applications/Amazon\ MP3\ Downloader.app/Contents/MacOS/Amazon\ MP3\ Downloader).

#lipo -detailed_info Amazon\ MP3\ Downloader.app/Contents/MacOS/Amazon\ MP3\ Downloader 
Fat header in: Amazon MP3 Downloader.app/Contents/MacOS/Amazon MP3 Downloader
fat_magic 0xcafebabe
nfat_arch 2
architecture ppc
    cputype CPU_TYPE_POWERPC
    cpusubtype CPU_SUBTYPE_POWERPC_ALL
    offset 4096
    size 1223796
    align 2^12 (4096)
architecture i386
    cputype CPU_TYPE_I386
    cpusubtype CPU_SUBTYPE_I386_ALL
    offset 1228800
#

Notice from the output above, the Amazon MP3 Downloader is a Universal Binary in that it supports the outdated PowerPC architecture as well as the 32-bit Intel architecture.  Also note, some files may only be i386 (32-bit Intel) binaries, or may be Intel only with both 64-bit and 32-bit architecture support.  Here’s an output example from Microsoft Messenger and the native OS X application Stickies:

# lipo -detailed_info Microsoft\ Messenger.app/Contents/MacOS/Microsoft\ Messenger 
input file Microsoft Messenger.app/Contents/MacOS/Microsoft Messenger is not a fat file
Non-fat file: Microsoft Messenger.app/Contents/MacOS/Microsoft Messenger is architecture: i386
# lipo -detailed_info Stickies.app/Contents/MacOS/Stickies 
Fat header in: Stickies.app/Contents/MacOS/Stickies
fat_magic 0xcafebabe
nfat_arch 2
architecture x86_64
    cputype CPU_TYPE_X86_64
    cpusubtype CPU_SUBTYPE_X86_64_ALL
    offset 4096
    size 117232
    align 2^12 (4096)
architecture i386
    cputype CPU_TYPE_I386
    cpusubtype CPU_SUBTYPE_I386_ALL
    offset 122880
    size 95408
    align 2^12 (4096)
#

The application that it appears safe to ‘thin’ in my examples would be the Amazon MP3 Downloader– however, I don’t know if Amazon will check the binary itself to see if it should be updated, or whatnot, so I will be doing this at my own risk.  I *could* copy the original app bundle to a CD or time machine as backup and then ‘thin’ the binary, but that may defeat the purpose, right?  It’s your call.  Completely.  And it’s your risk.  Completely.  Use your tools and inform yourself before you start whacking stuff you have no clue about.  Do we have the disclaimer clear?  Good.  If not– don’t use LIPO.

If you decide that you like the risk and can manage a mangled binary (even if it costs you a down computer or forces you to reinstall– did we mention disclaimer and it’s your risk entirely), you can use the following command to strip a Universal Binary’s PowerPC code:

THEORY:
#cd /Applications
#lipo <APPLICATION_NAME>.app/Contents/MacOS/<APPLICATION_NAME> -thin i386 -output  <APPLICATION_NAME>.app/Contents/MacOS/<APPLICATION_NAME>.i386
#cd <APPLICATION_NAME>.app/Contents/MacOS/
#rm <APPLICATION_NAME>
#mv <APPLICATION_NAME>.i386 <APPLICATION_NAME>

 

PRACTICAL EXAMPLE (Using Amazon MP3 Downloader application as an example):
#cd /Applications
#lipo Amazon\ MP3\ Downloader.app/Contents/MacOS/Amazon\ MP3\ Downloader -thin i386 -output  Amazon\ MP3\ Downloader.app/Contents/MacOS/Amazon\ MP3\ Downloader.i386
#cd Amazon\ MP3\ Downloader.app/Contents/MacOS/
#rm Amazon\ MP3\ Downloader
#mv Amazon\ MP3\ Downloader.i386 Amazon\ MP3\ Downloader

 

The above list of commands will put your terminal in the Applications directory, create an i386 architecture only version of the Amazon MP3 Downloader binary (Amazon MP3 Downloader.i386), remove/delete the original Universal binary, and then rename the i386 version to the standard version so existing references to the file operate normallly.

For those with a binary that has both 64-bit and 32-bit architectures but no PowerPC arch– I’m sure the procedure would work the same, but I’m not sure I would do it– I’d want to test it first on a non-critical file– so far I haven’t done so.

So what did I do?

PHYSICAL SURGERY!

Although I’ve thinned a few Universal Binary files, I had a lot of pictures and home videos that were consuming the majority of my space.  Rather than face the tedium of ‘lipo’ on a large scale, I opted to go for replacing the hard drive in my iMac 24″ (early 2009 model).  Is this something I’d recommend?  Only if you’re up to the job and know the risks.  I’m a former Apple Certified Technician (waay back in the ’90’s working with MacOS 6/7/8/9 and Mac OS X 10.0 (PPC only).  I was a little leary, since I didn’t have my old tool-case with all my Apple tools, and no access to the Apple technical documents.  I proceeded anyway– I needed the space.  Bad news is that, in my case, when I tried to remove the 640GB hard-drive, the plastic retainer broken!  Luckily, it wasn’t in such bad state that I couldn’t use it, but it was close.  What would I have done if I couldn’t put my new 1.5TB hard drive in my iMac?  Crud!  I’d be freaked out!  I can’t afford no stinking Apple Certified Technician and repair bill?

Anyway, I replaced my Hard Drive.  I even took some photos, but realized that they would be relatively worthless since Apple changes their designs so often.  I looked on YouTube and found an Early 2009 iMac 24″ Hard Drive replacement video– and the parts in my system were NOT what I saw in the video.  SO… if you decide to replace your hard drive, DO YOUR RESEARCH.

Leave a Reply

Your email address will not be published. Required fields are marked *