Articles October 6, 2004 at 10:58 pm

Disk Imaging for Mac OS X Server

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.

<code>&lt;b&gt;What You Will Need&lt;/b&gt;

&lt;p&gt;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. &lt;/p&gt;
</code>

Step-by-Step Instructions

  1. Get The Destination Machine Ready
  2. 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

    ifconfig en0
    

    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.

  3. Get the Controller Machine Ready
  4. 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.

  5. Do the Initial Installation
  6. 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.

  7. Locate the Server From the Controller
  8. On the controller Mac, open up a terminal window and type

    /System/Library/ServerSetup/sa_srchr 224.0.0.1
    

    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
  9. Connect to the Server Using SSH
  10. From a terminal window on the controller machine, type

    ssh [email protected]
    

    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.

  11. Update the Server
  12. 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

    softwareupdate --list
    

    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.

  13. Get the Server Ready for Imaging
  14. 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.

  15. Image the Server Volume
  16. 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

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.

No Comments

  • In step 8, I think you need to do a get info on the mounted target volume and
    uncheck "Ignore ownership on this volume" or your resulting image may end
    up with the wrong ownership settings.

  • I’d also recommend throwing the latest Xcode Developers tools on the image
    too.

    Just put the Xcode CD in the drive of the destination machine, and from your
    SSH connection on your controller machine type:

    installer -pkg /Volumes/Xcode\ Tools/XcodeTools.mpkg -target /

  • I’d just like to make quick backups of my system before updates with the
    intention of creating the ability to roll back to the EXACT state I was in before
    the update. Is there any reason why this can’t by just booting off of the OS CD
    and using the Disk Utility app to create an image? Do the BootCache, ssh_hosts,
    etc. files really need to be deleted if I just want to roll back to where I was? I
    wouldn’t think so, but this just seems to easy.

  • Still works fine for me, using OSXS 10.4.7 Universal (don’t know about PPC).
    Have also proved the ‘universality’ of such an image, creating it on a CoreDuo
    Mac mini, and imaging it onto a G4 Mac mini – so far without problems.

    A question to the wise: when imaging OSX/OSXS, how critical is it to remain
    within the same hardware family (e.g. Xserves, Power Macs, Mac minis)? Or is
    such an image truly hardware-agnostic?

    Another tidbit that could be of interest: I have successfully installed a NIC
    driver (via a package installer) before server configuration, using the technique
    described in this article. As a result, I was able to configure this NIC as part of
    the server setup routine. Nice! 🙂

Leave a reply

You must be logged in to post a comment.