Sleepimage and you: How to free extra drive space on MacBook
more from
apple
Mar 30, 07
I've noticed that my hard drive space decreases by 3 to 5 gb after a clean restart. Why? I didn't know, and decided to do some investigation.
What I found is that on MacBook + MacBook Pro laptops, OS X will automatically create and maintain something called a "sleepimage". Basically if your computer loses all power, OS X can recover your system state from the "sleepimage". I guess that's nice, but also a bit unnecessary I think... in 4+ years of using a laptop as my primary computer, I've never lost power completely.
From what I found, the sleepimage is a copy of your computer's current system memory, and it's size is directly related to how much ram you've got. If you have 512mb ram, sleepimage will be 512mb. If you have 2gb of ram, your sleepimage will be 2gb.
The sleepimage is stored on disk as a physical file, so if you have a 2gb sleepimage, that's 2gb of hard drive space that you cannot use for anything else (applications, files, etc.). I no like.
The sleepimage lives under /var/vm, and you can see how much disk space you're currently sacrificing to it by opening a Terminal window and typing the following command:
ls -lh /var/vm/sleepimage
Here's what it looks like on my MacBook Pro with 2gb ram, showing that my sleepimage consumes 2,048 mb on disk (or 2gb). Yikes.
% ls -lh /var/vm/sleepimage
-rw------T 1 root wheel 2048M Mar 30 05:36 /var/vm/sleepimage
So how do you turn this off? To disable the automatic creation (and update) of sleepimage on your MacBook and permanently free up that disk space, do the following:
- Open a Terminal window and type the following (enter your password when prompted):
sudo pmset -a hibernatemode 0; sudo nvram "use-nvramrc?"=false
- Restart your computer
- Open a Terminal window, and take note of your current sleepimage's size by entering this command:
ls -lh /var/vm/sleepimage
- Now that you've restarted OS X, you can manually remove the sleepimage file:
sudo rm /var/vm/sleepimage
- That's it, you should now have that extra space permanently available on your laptop.
Note: this should also speed up the time required to put your computer to sleep. Without this change, each time you sleep your MacBook/MacBook Pro OS X will take a little while to update the sleepimage. Once you've disabled the sleepimage, it will skip that extra work. As a result, your laptop should sleep much more quickly now (5 seconds vs. half a minute).