How to manually partition (“Boot Camp”) your Mac for Windows 7

Posted November 30, 2010 by Ben in Apple Mac

This Tech-Recipe will show you how to MANUALLY modify an existing Mac hard disk to allow a Windows installation. Have you ever wanted to know what’s under the hood when you run the Boot Camp wizard? Ever wanted to modify a Mac GPT disk with an existing HFS+ partition to allow a Windows installation to occur without having to boot from the destination disk to begin with (“Target Disk Mode”)? Read on…

The essence of an Intel-based Mac is the new firmware and disk partitioning scheme. This is nothing new to most, but many folks who are interested in running Windows on their Mac still do not know how it works.

A classic x86 (PC) machine uses Basic Input/Output System (BIOS) with a Master Boot Record formatted disk. An Intel-based Mac uses Extensible Firmware Interface (EFI) with a GUID Partition Table (GPT) formatted disk. Intel developed the latter for use with Itanium-based systems, but if you’re interested in a more elaborate explanation please look here:

A GPT formatted disk does not contain a “real” Master Boot Record. Current Windows Operating Systems require a Master Boot Record formatted disk (one that accurately references all partitions using MBR) to boot from. The GPT specification requires that the first 512 bytes of a disk be reserved as a place-holder, essentially containing an MBR that simply indicates one partition which occupies the whole disk, where a traditional MBR disk usually locates its partition table and boot code. Apple utilizes their diskutil application to create an MBR on a GPT formatted disk, thus allowing Windows to install and boot. The Boot Camp utility simply uses this utility “under the hood” to make this easy for the average user.

Let’s take an average Intel-based Mac, running with a single hard disk formatted as a GPT disk (the default). Open Terminal, and run fdisk on the boot disk (normally /dev/rdisk0) to see the MBR. It will show you an effectively “empty” partition table:

sudo fdisk /dev/rdisk0

Running the above command on a machine that does not contain a “Boot Camp” partition will result in a listing of an effectively empty disk. This will differ greatly from the output of the following command:

diskutil list

Which will list the currently mounted disks and their respective partitions and filesystems. You’ll probably note that you seem to have two partitions, even though you only have one that is usable. The first partition, all ~200MB of it, is actually used by EFI and is not really “usable” space. A further elaboration of the details of any given partition can be had with a command such as the following (this example for partition #2, the boot partition, on the average Mac):

diskutil info /dev/disk0s2

Which will list many useful details, including “Bootable” status and free space. If you wish to create a “Boot Camp” partition from which to boot Windows you’ll really be creating a third partition on your GPT disk, using some of your available free space, and then creating a Master Boot Record to allow Windows to reference and boot from said partition.

In my case, my November 2007 MacBook Pro has an aftermarket 320GB Western Digital 7200 RPM “Black Edition” hard disk. Having approximately 120GB in use, that leaves usable free space of about 200GB. I wanted about 70GB for Windows, so I ran the following in Terminal:

diskutil resizevolume /dev/disk0s2 250G MS-DOS “Win7” 65G

This command uses the diskutil “resizevolume” option to change an existing partitioning scheme, non-destructively, from a single HFS+ partition (which is really two partitions), to a dual-boot, “Boot Camp” compatible partitioning scheme. In my case, the existing partition is resized to 250 GB with the “250G” option. Then an additional partition is created, along with a Master Boot Record, with the “MS-DOS” filesystem option, the “Win7” volume label, and the “65G” size specification. Note that 65 GB is actually somewhat smaller than the actual resultant partition/volume size, but diskutil automatically sizes the last specified partition/volume to occupy available contiguous free space.

After running this, I have a 250 GB volume for OS X, and a 69.73 GB volume for Windows 7. The “Win7” volume is formatted as FAT by default, but can easily be changed later when installing Windows.

In your case, the disk sizes and volume free space may vary. You should adjust as necessary, and, for goodness sake, make a backup with Time Machine before you change a thing!

Now, if you run “sudo fdisk /dev/rdisk0“, you’ll see that there is now a Master Boot Record on the GPT-formatted disk. This means that Windows setup will now allow you to install Windows on your Mac hard disk without destroying the existing OS X install (as long as you carefully choose the install partition!!).

The next step is simple: pop in the Windows 7 installation media, reboot, hold the Option key, and choose the Windows CD to boot.

Once booted to the Windows installer, the only trick is to choose the correct partition to install to. In my case, and the case of most “Boot Camp” users, this will be “Disk 0 Partition 3”. You will need to select this partition, choose advanced drive options, and select Format to make it available for installation. This re-formats the “MS-DOS” volume from FAT to NTFS.

Once Windows is installed you will of course need to install “Boot Camp” drivers. In my case, I chose to install Windows 7 64-bit, and this required a bit of extra work to get the drivers installed as it is not officially supported on my model. I was able to get everything working quite nicely by putting in the Snow Leopard CD while booted to Windows, copying the drivers folder to my C: drive, running an elevated command prompt, and using “msiexec.exe /i bootcamp64.msi” to run the installer directly out of the “Apple” folder. Let me know if you need further help with that part…

Armed with a bit of understanding (hopefully this is something that you have gotten from this Tech-Recipe), you can now perform some more advanced partitioning for Windows on your Mac. For example, have you ever wanted to create the “Boot Camp” partition while booted to the OS X installation media (using Terminal)? Or perhaps pre-create partitions on a USB disk or a Mac running in Target Disk Mode? Simply modify the device identifier as appropriate (again, use: diskutil list), and you’re in business. In most cases, this is as simple as replacing /dev/disk0 with /dev/disk1 or /dev/disk2, etc.

If you wish to use Terminal to perform the initial partitioning of a disk (completely wiping the disk’s contents), and include the “Boot Camp” partition from the beginning, you can do that as well. For this you use the diskutil “partitiondisk” option. Let’s assume for this that you’re working with a Mac with a 320GB disk booted up in Target Disk Mode, connected via Firewire to the Mac on which you’re running Terminal. Again, use diskutil list to find the disk identifier. Let’s assume it’s /dev/disk1. Create the partitions like so:

diskutil partitiondisk /dev/disk1 2 GPTFormat JHFS+ MACHD 250G MS-DOS WIN7 65G

This will create two usable partitions on /dev/disk1. The first will be 250GB, formatted as Journaled HFS+, and labeled MACHD. The second will be the size of the remaining free space (which must be greater than or equal to 65G for the syntax in my command to work), formatted as FAT, and labeled WIN7.

The Conversation

Follow the reactions below and share your own thoughts.