Creating a Mac OS X Bootable CD

* Introduction

Note: Please do not email me about this tip.  This is what I know and I haven't spent time working on this in months. These instructions also have not been tested on Jaguar. Thanks!

Bootable CDs have long been a troubleshooter's primary tool for Macintosh computers. It has always been quite easy to create a disk that boots most Macs that also contains not only the tools to repair disk errors and directory problems, but also to gain network access and access to peripherals such as Zip drives to back up data from an unbootable disk.

Mac OS X seems to have changed that -- if a bootable disk that provides the functionality indicated above is possible, surely it isn't that obvious. Fortunately, however, Apple has provided some of the tools to get us started on the road to creating such a disk: hdiutil, ditto, and Disk Copy. Below I've outlined the principle of creating a CD that will allow you to boot into Mac OS X with the following services:

  • Finder
  • Dock
  • Access and use of most applications (esp. Disk Utilities)
  • Access to your disk drives
  • Network access
  • Installation capabilities

I suggest that you dedicate a partition on a local or firewire drive to develop your rescue disk. Please note that these instructions essentially show you how to create a disk that will boot a Unix operating system. I have decent Unix skills and it took weeks for me and my collaborators to develop this methodology. Do not begin this endeavor thinking it will be easy or that it won't require strong Unix skills. Charles Srstka is currently developing a utility called BootCD that will make the entire process easier; if you're at all apprehensive of the command line, you may want to try that instead.

* Setup your System on the test disk

I will assume that you are developing your disk on read/write media. First, you need to either install Mac OS X on the test disk or copy some of your current system to the test disk (its probably easiest to install it). When it comes to making Mac OS X functional, it is much easier figuring out what you DON'T need rather than what you DO need, so starting with a fully functional system will make the whole process much easier.

Items that are probably safe to remove from your test disk to save space:

  • Most default applications that you wouldn't use on a rescue disk
  • /Library: CFMSupport, Desktop Pictures, Documentation, Image Capture, Internet Search Sites, Keychains, Logs, Modem Scripts, Preferences, Printers, Receipts, Screen Savers, User Pictures, WebServer
  • /System/Library: Image Capture, (any Preference Panes you don't plan to use), Printers, Screen Savers, Services, Speech, UserTemplate
  • /System/Library/Fonts (keep the following fonts):
    • Courier.dfont
    • Geneva.dfont
    • Helvetica.dfont
    • Keyboard.dfont
    • LucidaGrande.dfont
    • Monaco.dfont
    • Symbol.dfont
    • Times.dfont

When removing these items, you should probably do a few at a time, then restart off your test disk to make sure nothing is broken. Another hint: go for the large (MB) items first, you're just trying to free up enough space to get this to fit on a CD with a little breathing room for other apps. The fewer things you have to remove, the more likely it is to work without too many problems. Now is also the time to add some applications of your own.

For the most part, you can leave the BSD subsystem alone. If you are desparate for space, there are probably some unnecessary items in /private, /bin, /usr, or /sbin, but finding them will be tedious and not very rewarding. You could, however, remove all the man page documentation in /usr/share/man. You better know your Unix, though, or have access to the references on another computer!

* Customize your root account

When booting from this disk, having constant root access will make troubleshooting much easier. To set this up, enable the root user in the NetInfo Manager (remember, you must be booted off the test disk to change these settings). Next, in the Login Preferences Pane, setup autologin for the root user. Reboot (from the test disk), then customize the root user's environment as you wish: Dock, Finder Toolbar, etc.

* Last-minute cleanup

Any swapfiles left on the disk will be taking up a lot of space. Remove them from /private/var/vm right before you're ready to move on to the next step. You can also remove log files in /private/var/log.

* Modify the startup parameters

This is the big step: now we will tell the disk to mount read-only, and to boot with a modified startup script. This step is important to test that the contents of the disk will work within the constraints of read-only CD media.

First, download my DiskManagement tools. This package is basically a few scripts that assist in mounting your disk drives despite not having write access for autodiskmount to do this automatically. To install these scripts onto your test disk, unstuff the archive with Stuffit Expander, then place it in the /Applications/Utilities folder of your test disk. It is important to place this folder in that exact location due to the configuration of the rc startup script (you can put it wherever you like as long as you edit the rc script).

Second, download my edited rc startup script. To install it, type the following in the Terminal (while booted from your test disk!!!):

cd /private/etc
tar -xzvf /path/to/rc.tgz

You may want to back up the rc script that is already in there in case something goes wrong and you need it to get back to where you were. At the very least, this will give you someplace to start. Read through the rc script to get an idea of what occurs during startup -- its very enlightening.

Finally, create some empty directories in the /Volumes directory for the supermount script to use on startup. I've created the following directories:

  • Aqua
  • BlackHole
  • disk1
  • disk2
  • disk3
  • disk4
  • disk5
  • disk6
  • disk7
  • disk8
  • disk9
  • Donut
  • Macintosh
  • Macintosh HD
  • Mike
  • Sarah
  • Video
  • Zip-100

Most of these are names of my disks, the rest are for the supermount script to use (read that script as well for some more insight into the disk-mounting dilemma).

* Create a bootable CD image template

When you create a blank image with Disk Copy, it has one basic partition, as you would expect. A bootable CD image, however, has hidden partitions that are responsible for it's ability to boot the machine. I believe these partitions hold information such as the drivers for the CDROM device and perhaps some critical booting code (I'm mostly guessing, though). To create a bootable CD image template, simply type the following in the Terminal:

hdiutil create -megabytes 650 -layout CD rescueimage.dmg

You may change "650" to "700" if you have a 700MB CD. After about a minute, the image will appear in whatever was your working directory in the Terminal.

Next, in the Finder, double-click on the image to mount it. You will be prompted to initialize it, and choosing to do so will launch Disk Utility. In Disk Utility, click on the "Erase" tab. In the list of disks, locate the 650/700MB image, click on its disclosure triangle, and select the empty, unnamed partition (see below). If you choose to erase the entire volume instead of the single partition, you will lose the important booting partitions! Give the partition a name (Rescue will do), then click on the erase button. When DU is finished erasing, select the newly formatted partition and select "Mount" from the "Options" menu. Quit Disk Utility.

* Copy your Rescue disk contents to the CD

You should be booted from your usual X installation. Use ditto to transfer the contents of your test disk to the CD image:

sudo ditto -rsrc /Volumes/testdisk /Volumes/Rescue

Then bless the System on the CD image:

sudo bless -folder /Volumes/Rescue2/System/Library/CoreServices \
-bootinfo /Volumes/Rescue2/usr/standalone/ppc/bootx.bootinfo

Finally, recreate the kernel extension cache for the CD:

sudo mkextcache -t ppc -d \
/Volumes/Rescue/System/Library/Extensions \
-o /Volumes/Rescue2/System/Library/Extensions.mkext

Special thanks to Charles Srstka for figuring out those last two commands -- these were the final piece of the puzzle!

* Burn the CD

Once your image is complete, dismount it and launch Disk Copy. Select "Burn Image" from the "Image" menu and select your rescue image. Disk Copy will ask for a writable CD -- insert one and click on burn. I suggest that you use CD-RW media, because it probably will take several hundred tries to get it right :-)

* Using a RAM disk

A RAM disk solves a lot of problems for a bootable CD, namely, having somewhere to create mountpoints on the fly. First, create a read/write disk image (you can do this in Disk Copy). Next, create the /dev entry for RAM using the hdid tool. Finally, copy the contents of the disk image to the RAM /dev entry and mount it. Because the disk image is mounted from the /dev entry, any changes occur in RAM.

Here are the Terminal commands which you could incorporate into the /etc/rc file:
[First, calculate the number of 512K blocks you need: numblocks = (image size in MB) * 2048; for example: 5MB = 10240 blocks]

hdid -nomount ram://numblocks
[result: /dev/disk1]

dd if=/path/to/image/file.dmg of=/dev/disk1 bs=512
[result:2866+0 records in
2866+0 records out
1467392 bytes transferred in 1 secs (1467392 bytes/sec)]

hdiutil mount /dev/rdisk1

You need to change the "1" in disk1 and rdisk1 to whatever number is returned by the first command.

* Alternative troubleshooting method

Having a bootable CD may seem very desirable, considering that it has been the pillar of troubleshooting the Classic Mac OS. With the stability of the new Mac OS, however, a bootable CD may be entirely unnecessary. I've already worked my way out of a couple hairy situations without a bootable CD, in fact, I didn't have to reboot my computer at all. With SSH (remote login) enabled, you can access and manipulate your user account to repair problems remotely. As far as disk or directory problems are concerned, you may be better off using an OS 9 disk with the numerous utilities that are available for OS 9 -- most work just fine on an OS X disk.

* Resources/Collaborators/Acknowledgements

I would like to acknowledge a couple of people who have been instrumental in the quest for a bootable X CD:

Eventually we will get this right and make it easy for the rest of the Mac community.

Originally Created on November 3, 2001
Updated 11/18/2001 to include some interesting points from "Paulo"

Updated 1/31/2002: completely changed the instructions. Now I recommend a destructive approach from a full installation rather than the constructive approach from an install CD

Updated 9/5/2002 to (finally) include a method for creating a RAM disk

see also :
    http://www.macmaps.com/bootcd.html#THIRDPARTY
    http://www.atpm.com/9.03/bootcd.shtml
    http://docs.info.apple.com/article.html?path=ServerAdmin/10.4/en/c1os3.html
    http://lonestar.utsa.edu/llee/install/bootdvd/
    http://xnews.soad.umich.edu/mirror/RsyncXCD_v2.1.dmg.tgz

 

arrow
arrow
    全站熱搜

    Bluelove1968 發表在 痞客邦 留言(0) 人氣()