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

Posted 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:

http://developer.apple.com/library/mac/#technotes/tn2006/tn2166.html

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.

  • Eric

    Great guide, by this I was able to get Windows installed. Didn’t work with the Assistant, and I was about to wipe the whole disk when I found your guide. Worked like a charm! Thanks a lot!

  • linus

    great, thanks, was looking for this solution for hours!

  • Dave

    Very helpful.

    From the text, it was not clear how to identify the MBR from the fdisk listing.

    If I am trying to copy an NTFS bootcamp partition to a new drive, is there any reason why the new partition can’t be directly specified as NTFS, and the old partition simply restored onto the new partition using ntfsclone, winclone, or one of the many Windows backup/restore/clone programs? What is the benefit of making a FAT32 partition and then having windows reformat to NTFS?

    Thanks,

    Dave

  • Will

    I selected Disk Utility->Partition and then clicked the Option button to create one partition with GPT rather than the default of MBR. Restoring a Winclone image then worked just fine.

  • Jay

    Great tutorial, but I tried but gave me this errormessgage? (using usb 4GB freshly formatted in macosjournaled, gpt, not thinking using macos so 2GB would suffice for the test) But it gave error

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

    Started partitioning on disk1
    Unmounting disk
    Creating the partition map
    Waiting for the disks to reappear
    Formatting disk1s2 as Mac OS Extended (Journaled) with name MACHD
    Initialized /dev/rdisk1s2 as a 2 GB HFS Plus volume with a 8192k journal
    Mounting disk
    Formatting disk1s3 as MS-DOS (FAT) with name WIN7
    newfs_msdos: 53522 clusters too few clusters for FAT32, need 65525
    512 bytes per physical sector
    Mounting disk
    Could not mount disk1s3 with name (null) after erase
    Error: -69832: File system formatter failed

  • Ernest

    hey gd guide! i was wondering if it is possible to increasing the available space on the already partitioned windows thru Terminal?

  • Jack

    Hi, this worked great to restore XP after I accidentally resized a partition wiping out my MBR. Would it be possible to use the terminal to create a “Triple-boot” OS-X, Win7, XP system on a 500Mb disk using the command (diskutil resizevolume /dev/disk0s2 300G MS-DOS “Win7″ 100G MS-DOS “XP” 90G)? or is is limited to only the 1 extra partition?

  • Maz

    hey,, thanks for this post …

    I did it step by step … all went through … except when I did the installation for windows and even after I formatted the partition … the Windows still was not able to do the setup .. I went back to disk utility and it shows the partition as NTFS … this is so strange … any idea how I can make the windows take it …

    the boot camp didn’t recognize the bootable USB that I maid … which is the same one works on the startup …

    I reallly appreciate ur help

  • John

    You sir, are a hero! This method worked when all others would not! Bootcamp assistant would fail, Disk Utility in recovery mode would fail but this…. Thank you!!!

  • a

    This only half-works.

    With current OS X (Lion), diskutil does NOT create a bootable partition. The docs suggest that this is “as expected”, so I don’t know whether Apple has changed their software, or if the article is missing a step.

  • Gertrude

    Thank you for this step, Bootcamp will not partition my internal HD, with this it should fix that to get win7 installed.

  • Taylor

    I got up to “diskutil resizevolume /dev/disk0s2 250G MS-DOS “Win7″ 65G” and then I kept getting a message saying Win7 was an invalid volume name. What can I do about this?

  • Nate Lawrence

    Hey there, Ben,

    I came across your article on manually creating the Boot Camp partition this morning and was going to give it a go…

    My Problem:
    When I type in your command, the terminal replies every time with the following error message:
    “Win7″ does not appear to be a valid volume name for its file system

    History:
    I’d previously used Boot Camp Assistant on Snow Leopard to install Windows 7 and later replaced that with various builds of Windows 8 as they became available.

    When the Mac got updated to Mountain Lion, however, it did something to my Boot Camp partition and unmounted it.

    When I attempted to take a look to see what was wrong with Disk Utility (from inside Mountain Lion) I was informed that that that version of Disk Utility didn’t work with Mountain Lion. (Really, Apple!?)

    I soon discovered that when restarting the Mac, you can go into the recovery partition and use Disk Utility from there. Unfortunately, I could not get the Boot Camp partition to mount. I tried to verify the partition but Disk Utility reported that it (the partition) needed to be repaired. I then tried the Repair option, but it failed and said that I’d need to manually back up files, then format the partition and proceed from there.

    I’d put this off for months, just in case I had a few irreplaceable files on there, but finally concluded that since the most recent build of Windows 8 I’d put on there was not that long before Mountain Lion killed it off and that I’d set all my working folders on external hard drives or to sync to SkyDrive etc. that I would be okay with reformatting it and just reinstalling Windows, so I went ahead this morning and reformatted it as FAT.

    Unfortunately, when I restarted the Mac and held [Option], after inserting my Windows 8 installation disc, I didn’t see the disc show up in the list of bootable devices. (I assume that this is due to there being no MBR.)

    I booted back to Mountain Lion to see if I could run through Boot Camp Assistant, but since the disk was already split into two partitions, it wouldn’t allow me to use it.

    I restarted back to Disk Utility and tried to simply delete the BOOTCAMP partition but could not easily see how to do that. Barring that, I tried reformatting the partition as MacOSX Extended (Journaled) in the faint hope that I might be allowed to merge the Macintosh HD partition with the empty BOOTCAMP partition and then be allowed to use the Boot Camp Assistant.

    Unfortunately not. =[

    At this point, I looked for help on manually creating the Boot Camp partition and found your tutorial. I was hopeful, however I already had a Boot Camp partition that I didn’t know how to delete and so couldn’t use your tutorial as is, as the empty partition (which I’d reformatted back to FAT) would be using the space that the terminal would be trying to create the new partition in.

    After a bit of searching, I found this tutorial which gave me a command to delete a partition from the terminal:
    http://www.techparaiso.com/89-steven-paul-jobs-apple-inc/apple-mac-osx/101-deleting-the-osx-mountain-lion-recovery-partition-tutorial

    My BOOTCAMP partition was disk 0 partition 4, so that worked well.

    I then came back to your tutorial and copied and pasted it in.
    My MacintoshHD partition is currently 268.48GB with 22.92GB free and the previous Boot Camp partition had been 50GB, but I decided I needed a little more, so your command to resize the MacintoshHD to 250GB and create a 65GB partition for Windows was actually pretty perfect.

    Which brings us to…

    My Problem:
    When I type in your command, the terminal replies every time with the following error message:
    “Win7″ does not appear to be a valid volume name for its file system

    I’m not sure what is going wrong or what volume name would be valid.
    Any help that you could offer me would be greatly appreciated.

    If I don’t hear back from you soon, my best guess is to simply use the first part of your command to resize my MacintoshHD partition back to using the entire disk, reboot, then try to use Boot Camp Assistant again (although it keep erroneously reporting that the disk is not journaled when according to Disk Utility – it is).

    Hope to hear back from you soon,
    Nate

    • Dennis

      > Hi all,

      I’ve just been following this guide, which seems to be correct, although it doesn’t include some information that would explain why the process fails in certain situations. Hopefully the following is helpful to those who are having problems.

      1) The volume name “Win7″ isn’t valid for a FAT volume. It needs to be in capitals (WIN7).
      2) Disk Utility maintains the MBR automatically and updates it whenever MS-DOS partitions exist. This means you don’t have to use the command line diskutil if you don’t want to.
      3) An MBR only contains 4 entries. If you have more than 4 partitions (including the new one), Disk Utility will just write 1 entry for the whole disk – this is the “protective MBR”.
      4) Mac OS 10.7+ includes a “recovery partition”. This takes up an entry in the MBR, as does “Macintosh HD” and “EFI”, so you only have room for 1 Windows partition within in the 4-entry limit of the MBR.
      5) The above limitation is due to the way Disk Utility writes the MBR. If you use something else to modify it, you might be able to squeeze in more entries, or combine entries for the non-Windows partitions.
      6) Quick fix: If you don’t mind losing your Recovery Partition, you can merge it into your boot partition using diskutility mergepartitions (read the manual carefully). This will give you 1 more MBR entry to play with.

      Obviously I’m not an expert on any of this – this is just what I’ve learned today. Please feel free to correct anything that’s wrong.

  • John

    There is a mistake in your syntax: diskutil resizevolume /dev/disk0s2 250G MS-DOS “Win7″ 65G

    “Win7″ is an invalid name. In order for this command to work, it must be typed in all uppercase “WIN7″, otherwise you will get an error. Thanks for the great info though!

  • Yames

    Hi, The partition method is very helpfull but I have an issue, after applying windows 7 the first restart didn’t go to Windows rather it went to Macintosh HD.
    Do you have any idea? cheers?