Sections
I've been spending a lot of time working on ways of imaging a Mac so it has both OS X and Windows XP installed and ready to boot. Yes, I know there are easy ways, but I wanted a good one that left all the hard work to other people and software.
Let me define the problem a little better. I have labs containing Macs that have to end up as dual boot. The Mac OS X image is no real problem, it installs using NetBoot and NetRestore.
On the Windows side I want to use exactly the same image as the Windows PCs in the labs. This is stored on an Altiris server and deployed to the Dell PCs using PXE. I also didn't want to have to do anything to that image every time it changed. I wanted it straight off the same server as the PCs.
The first problem, and easiest to solve, is that the Mac doesn't support PXE. Fortunately I discovered that if I ask nicely the guys in charge of Altiris deployment can create a PXE boot CD that includes all the same tools that you get when you boot a PC over the net. Then you just have to run Rdeploy and grab the image.
After that things get complicated. You need something that can fiddle the partition table and Master Boot Record (MBR) and you also need a way to get the Mac drivers into the right spot so Windows sysprep can install them.
The first solution I came up with used rEFIt to do the partition table and MBR fiddling. Getting the drivers into place required rebooting off the PXE CD a second time (Altiris leaves the imaged partition read only the first time) and running a batch file (copied into the CD ISO and then reburnt onto the CD.)
That was way too many boots and I had to uninstall rEFIt as it's not the greatest boot picker for a lab. I wanted to use BootPicker since it leaves the Mac open to an Apple Remote Desktop session and allows a nice screen explaining when to use each OS and all the reasons Mike Bombich built it, nicely explained on its home page.
I could personally get it right nine times out of ten but it was too hard for support people.
So I started on a search for another solution. Thanks to some notes on Mike Bombich's site on how he does it under the hood with NetRestore and some notes and tools from Tim Parfitt I discovered that it was possible to do the partition table and MBR fiddling from the Mac. That only leaves getting the drivers into place.
Unfortunately ntfscp, from ntfs-tools, doesn't create directories and we need an entire tree - not something I was happy asking the Windows imaging team to add to their images.
It was time to bite the bullet. I'd spent hours researching other ways that didn't add a possibly flakey third party driver to my Mac image but it couldn't be avoided. Adding the drivers would need MacFUSE and ntfs-3g.
To quote from the MacFUSE homepage “MacFUSE implements a mechanism that makes it possible to implement a fully functional file system in a user-space program on Mac OS X (10.4 and above). It aims to be API-compliant with the FUSE (File-system in USErspace) mechanism that originated on Linux.” ntfs-3g is an open source NTFS driver for various *nix operating systems. Both are quite stable.
Installing them is easy, and once on reading and writing to an NTFS partition is as easy as any other. The one thing you have to be careful of is that the partition type 'ntfs' has disappeared to be replaced by a generic 'fusefs' which covers all the file systems you have installed with MacFUSE. This was critical for my shell scripts as I detected the presence of an installed Windows image by looking for an NTFS partition.
You can see the code here. If you need a copy of gptrefresh you can grab it from inside NetRestore. Just right click on the app and choose “Show package contents”.
I advise you to test it line by line on your system. Just remember to put 'export' in front of any shell variable definitions so they stick from command to command. When it comes to testing the fdisk command you can run fdisk, enter the commands from the printf and watch what they do. Of course I also suggest you read the man page for each command to understand what they are up to.
When testing having rEFIt installed is useful as it allows you to watch the partition table after each boot.
Finally, many thanks to Mike and Tim for their great tools and excellent notes. It's standing on the shoulders of giants that makes my job easy.