Learn how to image a virgin install of OS X Server.
If you are looking to roll out a number of server installs from a disk image, or you just want to be able to roll-back your test server quickly, read on.
You can save yourself a lot of time setting up a whole bunch of machines if you create a disk image with the necessary updates already installed, thne just slap that image onto each of the machines. Creating a disk image for a Mac OS X client installation is straightforward and well documented; you can look at the afp548.com article about it, or just open a terminal window, type man asr, and follow the instructions. However, creating a disk image for a Mac OS X Server installation is undocumented and more difficult.
When you create a disk image for a Mac OS X installation, you go through the initial setup creating a user account, then run Software Update or attach a FireWire disk with the update packages and bring the machine up to date. Afterwards, you delete a couple of files and a couple of NetInfo entries and you’re back to the initial state, ready to set up the first user account. This won’t work for Mac OS X Server, though — the initial setup steps are much more complex and are not easily reversed. So how can you create a system to be imaged that has all of the updates already installed and is ready for setup?
The secret is that Mac OS X Server has a root account that that you can access via ssh, even if you haven’t gone through the setup yet! This is how you can do a remote setup through Server Assistant. By utilizing this account, you can use command line tools to get your system ready to go without running through the setup assistant and embedding all kinds of invalid configuration information into your disk image.
What You Will Need
You need two Macs (one as the destination for the Mac OS X Server installation and one to control the process), Ethernet and FireWire cables, and an Ethernet network with access to the Internet. The Internet connection is not strictly necessary, but makes the process easier. Make sure that the two machines are plugged into the network. You definitely will need an Ethernet network — using AirPort for this won’t work due to the way that the server tools function.
- Get The Destination Machine Ready
- Get the Controller Machine Ready
- Do the Initial Installation
- Locate the Server From the Controller
- Connect to the Server Using SSH
- Update the Server
- Get the Server Ready for Imaging
- Image the Server Volume
You’ll need the serial number of the destination machine and its MAC address, so that you can login as root via ssh. These should be on the back of the machine, or you can use the ioreg and ifconfig command line tools to look them up.
Boot the destination machine from the Mac OS X Server install CD and open up a terminal window from the menus. At the command prompt, type
ioreg -l | grep IOPlatformSerialNumber
and hit return. This will dump out the serial number of the machine — write it down. Next, type
and hit return. This will dump out information about the built-in Ethernet interface. Write down the MAC address, which will be of the form aa:bb:cc:dd:ee:ff.
Any Mac running Mac OS X 10.3 will do, but you need to install the Mac OS X Server admin tools, which you can get from Apple’s website at http://docs.info.apple.com/article.html?artnum=120280.
Run through the normal installation process for Mac OS X Server using the two install CDs. At the end, you should have a server quietly sitting there waiting to be set up.
On the controller Mac, open up a terminal window and type
and hit return. You should see the MAC address of the server that you have set up, its IP address, and an indication that it is a server waiting to be set up. Hhere is a server waiting to be set up might look:
dhcp6.example.com#unknown#192.168.1.6#00:30:65:b8:9b:ef# Mac OS X Server 10.3.0#RDY4Setup#2.0#0
From a terminal window on the controller machine, type
and hit return. When the server asks you for a password, enter the first eight letters and digits of the serial number that you noted down in step 1. The password is case sensitive. If you are working with older hardware such as a blue and white G3 tower or one of the earliest G4 towers you may need to use the password 12345678 instead.
Congratulations! You now have a root shell on your server, and can do just about anything. What you’re going to do is run the command line tool softwareupdate, which will tell you what updates are available for your machine. Type
and see what updates are necessary for your machine.
To install an update, such as the Security Update 9-30-2004, run the softwareupdate tool again, only using the command
softwareupdate --install SecUpd2004-09-30Pan-1.0
This will download and install the Security Update 9-30-2004. You will probably want to avoid doing the updates for some of the packages that just don’t make much sense for a server, such as the iChatAV and iPod Updater updates. You don’t need to restart between updates.
After you install all of the updates from the initial list, run the softwareupdate --list command again, as some of the updates you just installed may have triggered other updates. Repeat the process until there are no more updates listed that you want to install.
When you’re done with all of the updates that you want to install, shut down the machine by typing
shutdown -h now
and hitting return.
If you don’t have Internet access, you can still do the updates. However, you need to manually figure out which updates are needed for the server, download them from Apple to a FireWire disk or CD-R, and install them using the installer command line tool.
Power up the destination machine in FireWire target disk more by holding down the “T” key when the machine boots up. Connect the destination machine to the controller machine by using a FireWire cable.
When the destination machine’s hard drive shows up on the controller machine&rsquot;s desktop, do a Get Info on it, open up the Ownership & Permissions section, and make sure that the option “Ignore ownership on this volume” is not selected. Change the volume’s name to something appropriate, like “Server”.
You will need to clean out some of the files from the server volume. Do the following commands in a terminal window:
sudo rm /Volumes/Server/etc/ssh_host* sudo rm /Volumes/Server/var/vm/swapfile* sudo rm /Volumes/Server/var/db/BootCache.playlist sudo rm /Volumes/Server/var/db/volinfo.database
Close the terminal window when you’re done.
Launch Disk Utility and select from the menus Images -> Image from Folder… (Do not select “Image from Server” or the restore won’t work properly.) Select the volume “Server”, and save the disk image as type “compressed”. Go get some coffee and come back as this may take a while.
When the imaging process is complete, scan the image for a restore by selecting from the menus Images -> Scan Image for Restore… and selecting the image you just created.
You can also do this step by using the command line tools hdiutil and asr.
You’re done! The image the you now have is a fully up-to-date, ready to set up Mac OS X Server installation. Just use Disk Utility or asr to restore the image onto a fresh disk and you’ll be ready to set up a new Mac OS X Server.