Posts Tagged ‘Mac OS X’
Using a virtual machine — perhaps VMware Fusion or Parallels Desktop — can result in way-too-large backups. Here’s one way to make those backups more manageable.
If you’re using a product such as VMware Fusion or Parallels Desktop to run another operating system on your Mac (perhaps Windows or Linux), then you may have noticed that your backups are now taking a long time. I documented one approach to solving this problem in an earlier article. Now here’s a different approach, originally suggested by Chris Ryder (thanks Chris).
First, here’s a recap of the problem. It’s written in terms of VMware Fusion but should be equally valid for other VM engines such as Parallels Desktop. If you’ve already read the previous article then you might want to skip to the meat of this article.
When you’ve been using Fusion’s virtual machine (in my case, to run Windows), you will find that Time Machine’s backup takes longer than expected — sometimes much longer.
This is because Fusion stores its virtual machines’ disks as a bunch of large files. When you run your virtual machine using Fusion (or Parallels Desktop), the contents of the VM’s virtual disk changes, and even if you haven’t made many explicit changes to files, all sorts of small changes happen to the virtual disk’s contents.
Incremental can still be too much
Time Machine performs incremental backups. That is, it copies only files that have changed since the last backup. Unfortunately those large files that Fusion uses to store the virtual disk’s contents? They’ve probably all changed, at least a little.
So, instead of your incremental being a few megabytes and taking a few tens of seconds, it’s ten gigabytes, takes ages, and rapidly fills your backup disk. (Which causes its own problems: described here.)
One solution: back up the VM in another way
One solution is to keep all your precious files in the Mac file-store, tell Time Machine to avoid backing up your virtual machine(s), and then back them up some other way. This results in the smallest backups and is useful if you don’t need sophisticated incremental backups of your virtual machines.
If this sounds like you, then I’ve shown how this can be achieved in an earlier article.
An alternative solution: use a sparse bundle
If you need proper incremental backups of your VMs, then one approach is to use a sparse bundle. This is a disk image which is stored as a collection of small files (typically 8MB), so when Time Machine backs up the disk image, it only needs to copy the files that have changed.
This approach still isn’t perfect — when (for example) Windows does anything, it tends to scatter its writes over the disk, so incremental backups are still large, but they’re not as large as when Time Machine backs up the VM directly. Typically, your incrementals may be a few hundred megabytes with no VMs, a few gigabytes with a VM stored on a sparse bundle (for Windows. Linux may be better behaved), and a few tens of gigabytes with the same VM stored in the standard way.
First lets create a new disk image based on a sparse bundle and move our VM onto it. We’ll need to know how large to make the VM, so go to Documents and look in Virtual Machines. In there is one folder per virtual machine and you can find the VM’s size by clicking on the corresponding folder and hitting cmd+I:
Create the disk image
Now create the sparse bundle. The point-and-click way of doing this is to use Disk Utility, so start that up (I use spotlight to do so):
and click on New Image:
Then fill in the details. I made my sparse bundle file-system for the Windows XP VM twice as large as the space it currently occupies, to allow for future expansion — so 50GB in my case (don’t worry: it only uses as much real disk as is needed to store the actual content). Here’s all the fields you need to change:
- The Save As is the filename for the sparse bundle whereas the Volume Name is the name the disk will have when mounted — I made them the same;
- I saved my sparse bundle in Documents->Virtual Machines;
- Image Format needs to be sparse bundle disk image, as that’s the whole point of the exercise.
Now click on Create, and
a few seconds later you have a sparse bundle file-system image.
Now double-click that file (mine’s called VM disk.sparsebundle).
Mac OS will mount it…
and the new file system will appear on the desktop.
Move the VM into the new disk image
Next, drag the folder(s) corresponding to the VM(s) you’d like backed up by Time Machine onto the new disk. Hold down cmd as you drag and drop, so that you move the folders (rather than copying them):
The .sparsebundle file needs to be mounted every time you log in, so that the file-store is available. To do that, go into System Preferences->Accounts, click on your username and then on Login items. Now drag your sparsebundle file into the list of login items:
Using your newly-homed VM(s)
To use your new VM(s), just double-click on the corresponding folder — perhaps put an alias to it on your desktop or in the dock. When you next use it you’ll get a message:
Just click on I moved it and you’re sorted.
As with any method of backup which relies on backing up the virtual machine’s disk image using the host operating system, your backup may not be of any use if it’s made whilst the VM is running, so I suggest you make sure that Fusion/Parallels is not running when Time Machine is backing up your data. If you don’t always manage to do so then some of your backups may not be valid.
Because if you backup the files that Fusion (or Parallels) is using for a disk image, then you’re backing up what’s on disk, but not what’s in memory, in disk buffers, etc. So when you come to restore from backup, you may find that the disk image is corrupted. In the worst case scenario you won’t be able to start up the VM’s operating system successfully at all, or restore any files contained within the VM’s file-store.
By backing up when the VM isn’t running, you ensure that all data is on disk in a safe, consistent state.
The Open Source Community and Microsoft do have something in common after all.
I was trying to figure out why firefox doesn’t sit as well on Mac OS as I’d expect — why it feels slightly alien on there (as does thunderbird), and then it occurred to me: firefox, thunderbird, et. al. are, in some ways, more akin to Windows than Mac OS.
I’ll explain (I think I’d better ).
Mac OS is pretty complete out of the box. If you’d like to burn an ISO image onto CD, or browse that ISO image, or ssh to another host, or use VNC, or… then it’s all already there, well integrated and working from the start.
Windows isn’t like that — the basic OS lacks a lot of functionality. If you’re going to burn an ISO, or browse one then you’ll need something like Nero. If you’d like to ssh to another machine then you download putty, if you’re going to connect to another machine using VNC then you’ll need that, and so on.
What you end up with is a whole host of extra software, all pretty much working, but all pulling in slightly different directions and all clearly written by different companies with different ideas about the user interface, and differing levels of integration with the whole.
Firefox and friends are also a little like that. The basic functionality is in the application, but all the extra frills are plugins, written by many different people. Many of the plugins are a little quirky, and they all tend to pull in slightly different directions — sometimes interacting badly with each other. It works, but it’s not elegant.
Microsoft and the Open Source Community do this for very different reasons. Microsoft does it to spread their programming effort as thinly as possible (I guess they’d say as efficiently as possible), always concentrating on ‘value’, and never on quality. The Open Source Community do it out of necessity: not everyone can be hacking the central code all the time, it’s just not practical, and the plugin approach enables a huge number of people to work on additional functionality whilst keeping the project manageable.
The world would be a much poorer place without open source software, but there is a price to pay. The plugin approach that open source development engenders leads to some great software (I wouldn’t give up my Squeezeboxes for the world for example, and my squeezeserver is bristling with plugins), but those systems do sometimes feel like they’re all elbows and knees — rather awkward, and somewhat less than elegant.
Want to use keyboard accelerators to drive dialogues etc. in Mac OS X? Here’s how.
Coming from the Windows to Mac OS, I missed being able to interact with dialog boxes etc. without having to use the mouse. There are times, especially with the MacBook, where clicking on an option is fiddly and error prone (in bed with a cup of tea for example ) and it would be much better if I could use the keyboard…
Here’s an example: here I am quitting from Safari. As is often the case, the dialog has reminded me that I don’t actually want to quit as I have multiple tabs, so I want to cancel the operation. Pressing return will close Safari, but how do I select Cancel? (Yes, I know you can press esc to cancel a dialog, but bear with me — the following solution works for all dialog selections and menus, not just Cancel).
The answer is to select All controls in Full keyboard access in Settings->Keyboard & Mouse->Keyboard Shortcuts:
Or, much easier , type ctrl+F7.
Now when that dialog pops up it looks different. Notice that Cancel is surrounded by a blue glow — that’s the dialog option that currently has keyboard focus, and pressing the space bar will select it.
Now you can navigate the dialog box using the keyboard: tab and shift-tab change the currently selected option, space selects that option, and return will always select the solid-blue default option.
So in this example, space will cancel the dialog and return will do the default action (close Safari in this case).
So you can now navigate dialog boxes on a MacBook, in bed, armed with a cup of tea — and I hear tell this even works with coffee, at a pinch
How to make Time Machine backup less (or more) frequently.
Apple’s Time Machine is a useful beast. Plug a disk into your Mac or buy a Time Capsule and Time Machine does the rest — waking up once an hour and copying anything that’s changed onto your backup.
However, you may not want a backup every hour — the backup disk is a limited resource. If you’re regularly changing large files then Time Machine is regularly writing large amounts of data to the backup disk, and if that’s the case then you won’t have backups going back very far into the past.
So there will be lots of revisions of files that have changed recently, but nothing much from, say, a couple of months ago.
So how do you change the interval?
The standard Time Machine options don’t allow you to change the backup interval (the time between backups), but the preferences are there to be changed if you know how.
From the command line
If you don’t want to install any extra software then you can change Time Machine‘s backup interval from a shell prompt. Start up a Terminal window and then type:
sudo defaults write /System/Library/LaunchDaemons/com.apple.backupd-auto StartInterval -int 18000
The 18000 above is the required backup interval in seconds — five hours in this example. And note that the above command is all on one line.
There are several full Mac OS applications out there that allow you to manipulate Time Machine‘s hidden preferences. The two most popular are Time Machine Scheduler and Time Machine Editor. I haven’t used either (being someone who leans toward using the command line), but they look like they’ll do the job. However…
My recommendation was, but is no more:
I did suggest using the Secrets prefPane to change Time Machine‘s backup interval (see below), but unfortunately that turned out to be bad advice. You can set the interval using the Secrets prefPane but it doesn’t stick. Quit the System Preferences application and start it up again and you’ll find the interval has gone back to the default of 3600 seconds.
So it seems Secrets prefPane doesn’t work for this after all! I’ll leave the rest of this article in place and perhaps someone will tell me when the problem’s fixed?
In the mean time, please use one of the options suggested above.
Here’s the rest of the original article, which at the moment doesn’t work: (more…)
How do you dump the screen in Mac OS X when you can’t reach for a hot-key-chord? The answer is grab.
Mac OS X Leopard has a tool to dump all or part of the screen built into the desktop, with handy (if difficult to remember) hot key-chords:
- cmd+shift+3 to dump the whole screen
- cmd+shift+4 to select an area of the screen (then press space for a whole window).
However, there are times when the above won’t do. Typically, it’s when you’re already pressing keys to get the image you need — the key chord cmd+shift+4 isn’t going to work if you’re already holding down alt for example.
That’s where grab comes in — it’s what Mac users used before cmd+shift+3/4 came along, it’s still there, and it can dump the screen after a ten second delay.
So, start up grab. I use Spotlight to do that, so I type cmd+space grab:
Then, to do the delayed screen dump, select Timed Screen from grab‘s Capture menu:
You then have ten seconds to set up the screen as needed, and grab does the rest.
Then select File->Save As… to save the resulting tiff file, and you’re done.
Need to go back to Safari 3? Here’s how.
So, you’ve tried the new Safari 4beta downloaded from apple.com, and now you need to revert to Safari 3?
That was case for me — as adding hyperlinks in wordpress caused the browser tab to hang (documented by Geek Guides here). However, if you’re thinking about returning to Safari 3.2.1 because you can’t input hyperlinks in wordpress‘ visual editor then think again — you may not need to — as there is now a work-around.
You still need to downgrade?
What doesn’t work
What doesn’t work is downloading Safari 3 and installing that — the installer complains that you already have a newer version on the hard drive and so won’t continue.
Is to re-run the Safari 4beta installer (fetch it from apple.com if you don’t still have it) and run the uninstall from there.
One reboot later and you’re back running Safari 3.2.1.
Safari image by timmargh.
Always open a file with a particular application in Mac OS X — the easy way.
First, the hard way
When you wish to open a file using a particular application, it’s simple. Just right-click on the file (ctrl+click) and select Open With.
The easy way
Fortunately there is an easier way.
Right click on the file as before, but this time depress the alt key. Hey-presto, the Open With option changes into Always Open With.
Changing the default application for all files of a kind
The above method sets the default application for this file only. If you’d like to change the default application for all files of a type (a kind in Mac OS speak) then here’s how to do it.
Windows-L for the Mac.
Coming to Mac OS X from Windows (XP and Vista), I missed being able to lock my session using a simple key-chord. I work in a shared office so it’s sensible to lock the session every time I walk away — something I do regularly.
In Windows, you simply press Windows-L and that’s it — time to go. Mac OS X Leopard doesn’t provide anything as succinct as standard, but there are ways.
Firstly, there are a couple of solutions that are accepted as standard ways of doing this — but unfortunately both have problems. I’ll cover these methods first in case they work for you, and then I’ll cover a solution that really is as quick and easy to use as the Windows’ lock screen key chord.
Partial solution number one: use a hot corner
A hot corner allows you to drop into the screen saver by moving the cursor to a chosen corner of the screen. To do this, first go to System Preferences->Desktop & Screen Saver and click on Hot Corners… Then select Start Screen Saver for one of the corners:
Of course, this doesn’t help unless your system is configured to require a password when woken from the screen saver. You can set that in System Preferences->Security:
And that’s it. Now, before you walk away from your Mac, just drop the cursor into the bottom-left corner of the screen.
However, there is a problem with this method — at least for me — as I don’t want the system to prompt for a password on wakeup. I end up typing my password far too often — every time I’ve left the machine alone long enough for the screen saver to start.
What I want is the Mac to remain unlocked until I explicitly lock it. So, on to solution two…
Partial solution number two: select a pull-down from the menu bar
Here’s another way of locking the machine, and this one doesn’t require that you tick Require password to wake up this computer from sleep or screen saver.
The trick is to enable fast user switching in System Preferences->Accounts->Login Options:
which will then place your user name in the menu bar at the top of the screen.
When you want to lock the session, just click on your user name:and select Login Window… and you’re done. (You can also achieve a similar result by ticking Show Status in Menu Bar in Keychain‘s preferences if you prefer.)
What’s my beef with this solution? The problem is that it’s still rather slow and fiddly — and it’s something I do regularly, so I want to just press and go, just as I did with Windows.
A full solution
First, download and install Dockables from cocoaapp.com. This gives you a bunch of useful applications in a sub-folder of your Applications folder:
and the one we’re interested in is Lock Screen.
Next, download and install Blacktree’s Quicksilver and run it to configure a new Lock Screen key-chord. Quicksilver will present you with its main window — just quit that and instead move to Quicksilver’s menu bar at the top of the screen and select Triggers… from the drop-down menu.
In the Triggers window that appears, click on the + at the bottom and select HotKey.
A new window will appear. Click on the first field and start to type lock screen. Quicksilver will rapidly find the Lock Screen dockable you installed earlier. Click Save.
You now have a new command, but with no trigger. So click on the None in your new command,
click in the input field labelled Hot Key: and press the key combination you wish to use to lock your session from now on. (I chose alt+cmd+L because the obvious choice — cmd+L — is already used by Thunderbird — my email client.)
I suggest you don’t use the ctrl key as part of your hot key-chord. If you do then quicksilver presents this dialog every time you type the chord:
Now, having typed a key-chord (which doesn’t include ctrl), exit the Triggers window and you have yourself a new Lock Screen hot key-chord: alt+cmd+L in the example above.
And finally, tweak some settings
You need quicksilver to run at all times, so bring up Quicksilver’s preferences (available from the Quicksilver menu in the menu bar at the top of the screen):
and walk away…
How to change the default application for al files of a given type in Mac OS X.
Under Mac OS X, you can easily open a file using something other than the default application by right clicking on the file (cmd+click) and selecting Open With. So, for example, to open a particular text file with MacVim I can do
And indeed, if I use the Other… option at the bottom of the above menu, I can change the default application for that file. (Although in practice I use an easier way.)
However, that’s only the default application for that one file changed — all other files of the same type will continue to open with the original default application.
To set the default application for all files of that kind (in this example, .txt files), you need to open the Get Info dialogue by right-clicking on the file (or typing alt+cmd I):
Now set the application in the file’s info window and click on the Change All… button, confirm by clicking Continue and you’re done. From now on, all files of this kind will be opened with your chosen application.
The quick, physical way to hibernate your MacBook.
When you close your MacBook’s lid, the machine sleeps. But you’ve probably noticed that it still uses power in its sleep — about 20% of the battery per day, so after about five days it’s flat.
What you may not know is that you can put the MacBook into a much deeper state, where the machine uses almost no power at all. A full battery will then last for months rather than days — useful if you know you’re not going to use your MacBook for a while.
Now, you could install freeware to put your MacBook into this deep-sleep state (often call hibernation) and indeed I have, and it’s good: Deep Sleep. But for the hell of it, here’s a physical way of doing the same, with no additional software required.
Hibernating your MacBook
Check it’s safe to do so
First, close your MacBook’s lid. The illuminated Apple logo on the lid will extinguish almost immediately, but we’re not looking at that.
Look at the light on the front:
It will eventually start pulsing (breathing in its sleep). If that happens almost immediately then sorry, but your MacBook is probably too old for this to work (it hasn’t copied its state to disk), so please don’t carry out the rest of these instructions — you may cause damage.
If, on the other hand, it takes tens of seconds before the light goes from solid-on to pulsing (typically twenty seconds or so) then your MacBook is recent enough for this to work, and you’re ready for the next step.
Let the fun commence
If the power light is now happily pulsing and it took a while to get to that state (whilst the MacBook copied its state to disk) then its time to interrupt the power.
Flip your MacBook over and press the battery-bay latch:
Then remove the cover:
and remove the battery, just for a couple of seconds:
Then put it all back together and hey-presto, the power light is off and its consuming almost no power at all.
When you next wish to use your MacBook, just open it up and press the power button. (Because it’s off off — really off — you do need to press the power button; opening the lid or pressing a key isn’t enough.) Mac OS X will begin to boot and then show a progress marker while the system’s state is restored from disk:
After a short while (about 35 seconds on my late-2008 MacBook Pro with 4GB of RAM), your MacBook will spring back to life in the same state as it was when you closed the lid, and with the same battery life!
How’s this work?
Modern Macs do what Windows Vista (for example) calls a Hybrid Sleep whereby it saves its state to disk as well as maintaining the same state using battery power. When you close the lid, the illuminated Apple logo goes off immediately so that you know it’s going to sleep, but actually the MacBook spends the next 20 seconds or so copying its state (mostly the contents of its RAM) on to disk. This is so that, should the battery go flat (and it will do within days, even if it’s full to start with), you won’t lose any data — you just have to wait longer for the machine to wake up once power is restored.
The MacBook then enters a light sleep (usually called standby) whereby the MacBook’s state is preserved by maintaining power to the machine’s RAM, and it’s that power feed that drains the battery.
When you pull the power for a moment, the machine no longer has any live state to preserve and so is essentially off and pulling no power. When you eventually switch it on again, Mac OS X restores its state from the hard drive and everything’s back as it was. It just takes a little longer, that’s all.
Here are some things you need to consider before indulging in any of above:
- You can’t do this on older MacBooks (the clue is in how long the power light takes to reach the sleeping state (pulsing on and off) — if it’s near instant then hybrid sleep isn’t happening and this isn’t going to work).
- You must wait until the power light is pulsing before pulling the battery;
- I suggest you don’t do this over-frequently (for example, every day is probably a bad idea) as the battery contacts may not be designed for such a high level of wear-and-tear. (Are there people who remove their MacBook’s battery every day for years on end? I wouldn’t be at all surprised.)
- Don’t plug in fresh USB devices whilst the Mac is asleep and then wake it from hibernation, as you may find your Mac is less than happy about it.
The software approach
If you don’t like the thought of removing your battery then not to worry — there are several software solutions that will also do the job, and there’s a good guide to them over at Geek Guides.