How to Create a Mac OS X System Disk Image
Note: These steps are largely based on the asr man page. (Open terminal and type "man asr")
- /usr/sbin/asr (Apple Software Restore) requires a properly created disk
image for most efficient operation. This image is most easily made with
Disk Copy's Image from Folder/Volume function (drag and drop the icon
of the volume into Disk Copy's window). Disk Copy from Mac OS X 10.2.2
(v54.3) or later is required. Disk Copy from Mac OS X 10.2.6 (v.55.6)
is HIGHLY recommended, as it fixed numerous bugs related to the copying
process.
- To create a disk image for restoration on another volume:
- Install OS X and set it up the way you want it. In general, the best way to do this will be to actually boot the volume, go through setup, create the accounts you want, dock items, applications, preferences, etc. You'll see later how to delete accounts and re-enable setup assistant to run on first boot.
- Boot from a different volume (e.g. firewire drive, or second volume on your primary drive). This isn't strictly necessary, but makes this easier.
- Enable the root user on the booted FireWire disk and login as root at the login window.
- Enable permissions on the volume you want to image. The easiest way to do this is to "get info" in the Finder and make sure the Ignore ownership on this volume is unchecked under the Ownership & Permissions tab.
- Create the system disk image:
- With Disk Copy:
- Launch Disk Copy from /Applications/Utilities.
- Under the "File" menu, select "New", "Image from Folder or Volume".
- In the "Image from Folder" window, navigate to the disk that you want to image and click the Image button.
- Save the image file as a read-write image so that you can delete unnecessary files (swap, etc) from the image file after it's created. If you create an image from a device, you will not be able to block restore it to any volume larger than the one you created the image on and you'll need as much file space as the disk size (80 GB hard disk will create an 80 GB image!) Creating an image from folder/volume is slower, but will give better results (stretchable, defragmented).
- If Disk Copy reports errors during the imaging process
(Ie: "Image Volume operation failed with error 2 (No such
file or directory)."):
- Run Disk Utility's "First Aid" on the volume that you want to image.
- Run Disk Utility's "Repair Permissions" on the volume that you want to image.
- Try Disk Copy's "File->New->Image from Folder or Volume" function again. If it fails, try to create the image from the command line, detailed in the next steps.
- Via the command line, in case Disk Copy doesn't work for
some reason! (hdiutil and ditto):
- In the /Applications/Utilities/Terminal application,
become the root user (sudo -s), create a sparse disk image
(hdiutil create), and mount the disk
image
with
Disk
Copy
(open):
sudo -s
cd ~
hdiutil create <DiskImageFilename> -type SPARSE -size 256g -fs HFS+ -volname "Macintosh HD Image"
open <DiskImageFilename> - ESSENTIAL STEP: Making sure that the disk image was mounted on the desktop (by the previous 'open' command), select it and "Get Info" from the "File" menu in the Finder. UN-check the "Ignore ownership on this volume" box under the Ownership & Permissions tab, so that we will NOT ignore permissions.
- Copy the master volume to the mounted disk image:
- In the /Applications/Utilities/Terminal application,
become the root user (sudo -s), create a sparse disk image
(hdiutil create), and mount the disk
image
with
Disk
Copy
(open):
ditto -rsrcFork /Volumes/<SourceVolumeName> /Volumes/Macintosh\ HD\ Image
- With Disk Copy:
- Unmount the original volume (Macintosh HD) that was imaged and mount the read/write disk image ("Macintosh HD Image" in this example) that was created.
- Clean up the image (remove unnecessary files):
-
sudo rm /Volumes/Macintosh\ HD\ Image/var/db/BootCache.playlist
(see TIL
article 107111)
sudo rm /Volumes/Macintosh\ HD\ Image/var/db/volinfo.database
sudo rm -r /Volumes/Macintosh\ HD\ Image/var/vm/swap*
- If you created the system disk image with hdiutil, rename the volume name of the mounted disk image ("Macintosh HD Image") back to the same name as the volume that was imaged ("Macintosh HD").
- Quit out of the terminal application. (If the current working directory is one of the directories in the disk image volume mount point the Finder will not be able to unmount the disk image.)
- Unmount the disk image.
- Essential Step: Convert the image to a compressed image
(asr won't scan/create checksum data on read/write images) using
Disk Copy's File---> Convert
Image... menus
or via the command line (the letter after UDZ is the letter "Oh" and not a zero):
hdiutil convert -format UDZO <pathtoimage> -o <ReadOnlyImageFilePath>
- Essential Step: Scan the image file (to create the checksum data):
asr -imagescan <ReadOnlyImageFilePath>
- Now PSU Blast Image Config (and /usr/sbin/asr) will be able to restore
the prepared disk image:
- Place the read-only and scanned disk image in a folder named "RestoreImages" in
the same directory as the PSU Blast Image Config tool:
chmod 644 /path/to/<ReadOnlyImageFilePath>
mv /path/to/<ReadOnlyImageFilePath> /path/to/RestoreImages - Use only [A..Z],[a..z],[0..9] in the disk image filename. I've only lightly tested disk images with spaces in their names.
- Place the read-only and scanned disk image in a folder named "RestoreImages" in
the same directory as the PSU Blast Image Config tool:
This site maintained by the Classroom and Lab Computing group of Information Technology Services.
Suggestions and comments about this web site: CLC Webmasters; Other contacts here.
This page was last modified: 7/7/2003 4:26:36 PM.