Scripts Part 4: Cloning — What's the Big Deal?
Boy, there sure are a lot of cloning apps out there. The mother of them all, of course, is Mike Bombich's Carbon Copy Cloner, but it's slowly losing mindshare to more aggressively marketed apps like the affable SuperDuper!. There are others, but I don't feel like scouring the web for them, nor do I feel like going to the effort of linking to them all. Suffice to say, there are plenty. Just search VersionTracker and you'll see.
I find the recent upswing in cloning utilities strange. Apple's bundled Disk Utility application has actually harbored the ability to clone a system disk for some time now (I believe as far back as Panther). And yet, it seems the easier cloning gets, the more apps there are with which to do it. And charge you for it.
Today's script uses a handy command-line utility that's actually been around since the Classic Mac OS days (though not, obviously, in command-line form): asr, which stands for Apple Software Restore. The asr command is essentially a command for cloning disks. In fact, that's exactly what it is. When Mac OS X first came out, asr was not bundled. But in recent incarnations of the OS it's hung around in the command-line, and it's actually gotten quite refined and easy to use. Want to clone your boot drive? Here's the command:
That's it. I can't imagine an easier command structure. In a way, it's almost easier to use than GUI apps that do the same thing. Of course you can get into some very complicated uses of asr, but for basic disk-to-disk cloning it's drop-dead simple.
Now there is one little, tiny bump in this road. Tiger, you see, has a brand spanking new way of making certain files on your boot drive invisible. You know, files like var and etc and private. And Tiger's version of asr (as well as Tiger's Disk Utility program) are none the wiser. So, if you want things set up properly, you need to explicitly set the visibility of these files. There are a few ways to do this. Today's script will use a utility called SetHidden, which comes on the Tiger install disc (a la this Apple KB article). Just so you know.
So here it is. A very simple script for making an exact clone of a volume to another volume. Please keep in mind, because of the file visibility issue, this script MUST be run from the disc image, or it will not work properly. Also keep in mind that cloning will overwrite, replace or even erase the target drive. I am in no way responsible for any damage you incur to your system with this script. If you don't feel comfortable using it, please don't.
That said, here's your free cloning utility.
Download ASRClone
I find the recent upswing in cloning utilities strange. Apple's bundled Disk Utility application has actually harbored the ability to clone a system disk for some time now (I believe as far back as Panther). And yet, it seems the easier cloning gets, the more apps there are with which to do it. And charge you for it.
Today's script uses a handy command-line utility that's actually been around since the Classic Mac OS days (though not, obviously, in command-line form): asr, which stands for Apple Software Restore. The asr command is essentially a command for cloning disks. In fact, that's exactly what it is. When Mac OS X first came out, asr was not bundled. But in recent incarnations of the OS it's hung around in the command-line, and it's actually gotten quite refined and easy to use. Want to clone your boot drive? Here's the command:
sudo asr -source [source_volume ] -target [target_volume ]
That's it. I can't imagine an easier command structure. In a way, it's almost easier to use than GUI apps that do the same thing. Of course you can get into some very complicated uses of asr, but for basic disk-to-disk cloning it's drop-dead simple.
Now there is one little, tiny bump in this road. Tiger, you see, has a brand spanking new way of making certain files on your boot drive invisible. You know, files like var and etc and private. And Tiger's version of asr (as well as Tiger's Disk Utility program) are none the wiser. So, if you want things set up properly, you need to explicitly set the visibility of these files. There are a few ways to do this. Today's script will use a utility called SetHidden, which comes on the Tiger install disc (a la this Apple KB article). Just so you know.
So here it is. A very simple script for making an exact clone of a volume to another volume. Please keep in mind, because of the file visibility issue, this script MUST be run from the disc image, or it will not work properly. Also keep in mind that cloning will overwrite, replace or even erase the target drive. I am in no way responsible for any damage you incur to your system with this script. If you don't feel comfortable using it, please don't.
That said, here's your free cloning utility.
Download ASRClone
Labels: Scripts, ScriptSharing
CCC started it all. Using ditto command. Cloning is HD to HD is similar but different to imaging, i.e. capturing a "build" to an image file (.dmg) then using that file to restore an army of clones. From the beginning in OSX asr worked one to one, but when NetRestore came out (by Bombich, as well), it was a the killer app. Disk Utility could not clone or restore. The best you could do was boot from an osx server cd and use terminal to run asr, but with NetRestore you could make an image, then store it on a server and netboot then rebuild each client in a lab. Of course now netinstall works from server and netrestore works well, and multicasting asr from any osx client (as server) to any other client is possible... But anyway, I mention all this to differentiate between cloning and imaging. And reasons why the distinction (lab rebuilds, vs safety backups). -matx
1:44 PM
Yes, this is an important distinction. Our lab is fairly small (only about 15 Macs to build each year), and we generally just clone machine to machine via firewire. So this simple ASR cloning is all we (and I suspect a lot of people) need. But, certainly, if you're doing imaging for a large number of machines, ASR might be a bit limited, and there are a lot of really nice tools out there for achieving these goals. I myself have been investigating the System Imaging Utility included with Mac OS X Server Tools for doing network installs, but I've yet to get it working. When I do, I'll post about it for sure.
Thanks for the comments.
-systemsboy
3:01 AM
In my last job, when I worked for a school, I had to reimage 200 machines in two days, every 2 months. In the beginning we did use firewire and disk to disk, but when NetRestore came out it changed everything. The best setup was netbooting entire labs, imaging and post-scripts would rename and put the finishing touches. Now I work in a smaller facility and I am using system image utility in 10.4 server to do this, in combination with NetRestore and the occasional disk to disk. It always depends on how many machines you have, and the amount of time available. Automation might be work to setup, but it's worth it with so many Macs. :)
7:15 PM
I'm still trying to crack the NetRestore/SIU nut myself. Never seem to have the time or resources to figure out how to get it working. Hopefully I'll have it by this Summer though. 'Cause yeah, it's clearly the way to go.
» Post a Comment