There are several ways to burn CDs in Mac OS X. Which method of CD-burning you should use depends largely on what kind of data you are burning to the CD. Let's consider an example in which we'll use a CD-R to backup ~/Library/Mail , which is where your mailboxes are stored if you use the Mac OS X Mail application. The same procedure can be applied to other data. We'll discuss how to accomplish this task with the GUI-based Disk Utility application located in /Applications/Utilities and by using the command line in Terminal. In either case, you should make a disk image before burning your data to a CD-R.
To make a disk image of ~/Library/Mail using Disk Utility, first make sure that no existing disk is selected, then select ~/Library/Mail in Disk Utility's Images New Image From Folder menu. A Convert Image pop-up window will prompt you to enter the name of the image you want to save, where you want to save the disk image and in what format, and whether you want to encrypt the disk image. This is illustrated in Figure 6-1, where we've chosen to save the disk image as backupmail2 (it will automatically be saved as backupmail2.dmg ) to the Desktop in read-only format and without encryption.
Figure 6-1. Creating a disk image with the Disk Utility
When the disk image has been created, it will appear in the left segment of the Disk Utility window. To burn this image to a CD-R, select the disk image in the Disk Utility window and click on the Burn icon in the toolbar. You will be prompted to insert a disc and to select some options for burning the CD, as shown in Figure 6-2.
Figure 6-2. Burning a disk image with the Disk Utility
The same task can be accomplished from Terminal using the commands, hdiutil and ditto . For example:
hdiutil create -fs HFS+ -volname BackupMail -size 200m ~/Desktop/backupMail.dmg
This creates a blank HFS+ disk image of size 200 MB named backupMail.dmg on your Desktop. Next, enter:
ditto -rsrc ~/Library/Mail /Volumes/BackupMail
This copies your Mail folder (along with all its mailboxes), which is located in ~/Library/Mail , to the disk image. Use the command ditto with the - rsrc option to copy resource forks and metadata.
Once this command has completed, enter the following command to unmount the disk image:
hdiutil unmount /Volumes/BackupMail
Finally, use the following command to burn the disk image to CD:
hdiutil burn ~/Desktop/backupMail.dmg