Native UEFI Windows 7 Boot on Mac Mini

There is a lot of confusion around the ability to boot Windows 7 using UEFI on a Macintosh. The confusion is based on the interaction with Bootcamp, MDR, GPT, BIOS Compatability Support Modules (CSM), rEFIt, 32-bit, install DVD formats, and bugs, combined with the inherent difficulty in understanding and debugging boot processes.

Facts

  • Windows 7 x64 (64-bit) will NOT boot natively using UEFI on a Macintosh!
  • Windows 7 x64 (64-bit) only supports installation on a UEFI 2.0 firmware using a GPT partitioned disk.
  • The Windows 7 x64 installation DVD is built with support for both BIOS (default) and EFI installation. During setup it is not obvious which version was used.
  • Windows 7 will only install on an MBR disk if booted using BIOS firmware.
  • Windows 7 will only install on a GPT disk if booted using EFI firmware.
  • Apple Macintoshes implement the EFI 1.1 standard, either 32-bit for early (pre-2008) Intel processors or 64-bit for more recent processors.
  • The Mac UEFI firmware contains a legacy CSM that presents a BIOS interface to allow non-UEFI aware OSes to boot and install.
  • Windows 7 x86 and x64 can be installed natively on a Mac in BIOS mode without MacOS or Bootcamp, but MacOS will not boot in BIOS mode.
  • Bootcamp is:
    • Set of Windows device drivers
    • Partitioning tool and MBR hacker
    • BIOS Compatability Support Modules in firmware

The Journey

The System

I purchased a Mac Mini (2.26 Ghz Intel Core 2 Duo, 4 GB DRAM, 320 GB disk) as a small compact desktop to primarily run Windows, but also support a few applications that had been previously running on an old PPC iMac. Primary purchasing decision factors included size, performance, and cost. I don’t have a lot of space in my home office so having a single large screen monitor that I can share is ideal. This ruled out the all-in-one systems like the iMac. I don’t need expandability beyond USB and Firewire, so space for extra PCI cards is wasted. I don’t play serious PC games (XBox if anything) so I only need a adequate 3D graphics. But I need more performance than what a Nettop (aka Atom based) system provides. Thus I ended up considering a number of systems (including a Dell Studio Hybrid), but when all things were balanced out, the Mac Mini had more features for less than a $100 price difference (sorry Steve).

Why Use UEFI?

I am an operating systems geek (Windows and Solaris) who has written more than my share of low level boot code. So with knowledge of Windows 7 support of UEFI, Macintosh support of UEFI, the idea of using Bootcamp tools to provide legacy BIOS support was just distasteful to me. I understand how useful it is for people wanting to run ancient Windows XP, but in the modern world of Windows 7 and Snow Leopard why bother with BIOS firmware? Not to mention 2 TB disks are rapidly approaching $100 and are too big for MBR partitioning. So all this modern technology should allow Windows and MacOS to live happily together in the UEFI world…

Keep It Simple

Of course the first thing anyone should do is to try the obvious, given that Windows 7 isn’t even available for retail systems yet I figured there hasn’t been much experimentation. So I inserted the Windows 7 x64 RTM DVD and booted holding the Alt/Option key, then I selected “EFI Boot” only to discover that just boots MacOS. Try again, this time I selected “Windows”. Success! The Windows 7 installation screens!

Not so fast…

Going through the Custom install menus to the disk screen, all of the partitions are unavailable with the error “The selected partition is of the GPT partition style.” Of course it is GPT, that is what I want. Something is wrong.

A little detective work later I discover that Windows will only install on a GPT partitioned disk if it has been booted using EFI, conversely MBR only if booted using BIOS. The Windows 7 DVD is built using the El Torito multiboot image format, the first (and default) boot catalog image is the BIOS (platform id 0) based etfsboot.com boot code and the secondary (platform id EF) is efisys.bin, the EFI boot application. Mac firmware when it detects a BIOS boot image adds the CSM driver and boots in legacy BIOS mode. I don’t know of any way to force the Mac firmware to pick the second boot catalog image.

EFI Only DVD

If the Mac firmware insists on using the BIOS boot code when present, the obvious solution is to remove it so only the EFI image is present. Microsoft has a nice set of tools (AIK/OPK) that allows you to create custom installation images, in particular the oscdimg.exe command is used to create bootable ISO images. All I need to do is copy the DVD contents to our local disk, create a new ISO image, and burn a new DVD.

md win7x64
robocopy /e /copyall e: win7x64
oscdimg -w4 -os -lWin7x64_UEFI_Only -m -o -n -pEF -e -bc:win7x64efimicrosoftbootefisys.bin c:win7x64 c:Win7x64_UEFI_Only.iso

Again, boot using Alt/Option and it fails…

WinPE

WinPE is the Windows Preinstallation Environment that is the stripped down version of Windows used for installation and recovery operations. Since I failed to create a EFI only installation DVD, it was logical to see if I could create a simple WinPE image. Again using the AIK and following the directions for Walkthrough: Create a Bootable Windows PE RAM Disk on CD-ROM I created a new CD.

Again, boot using Alt/Option and this time there is an “Efi Boot” but with a new icon. Selecting it and the CD starts spinning but the screen doesn’t change. Remembering that Windows prompts you to “hit return to boot” from CD, I do so causing more CD activity but ultimately it fails. Sounds like progress, but I can’t really tell.

Maybe some interesting activity or error is being hidden by the Mac graphics image? A bit of searching and there are some posts that indicate any EFI text messages will not be displayed due to the Mac being in graphics mode.

rEFIt

rEFIt is an open source EFI shell which is used by many Mac enthusiasts. It solves the big problem that Apple does not ship a real EFI shell in its firmware. By downloading and installing rEFIt I can intercept the boot process and actually see what is happening.

Although Apple creates the required EFI System Partition (ESP), it does not populate it or use it for anything because its firmware already has all the required drivers (e.g. HFS+) built in (and why would you want to boot anything else?). For my experiments, I don’t want to mount or use the MacOS partitions, so I need to install rEFIt on the hidden EFI system partition using Felipe Alfaro’s “expert” directions.

Now I can boot into rEFIt and get a real EFI shell to play with. (Hint: add “-b” to commands to page output) Running the “ver” command shows that Apple has only implemented the 1.1 specification.

With the original Windows 7 installation DVD inserted, I can select fs2 and execute the BOOTx64.EFI command from the DVD:

Shell> fs2:

fs2:> EFIBOOTBOOTX64.EFI

Now I can see it going through the expected boot messages including the progress bar that indicates that it is loading the Windows files. The DVD disk sounds are similar to what I heard with the WinPE image so I suspect that previous image was correct.

But it does not boot and appears to just hang.

Rebooting into the EFI shell again, I run BOOTX64.EFI again, but this time I hit F8 which brings up the boot menu asking if I want Safe Mode. I select Safe Mode with Command Shell and watch all the boot drivers being loaded, but again it fails to boot.

All of this leads me to the conclusion that I am loading Windows using EFI and getting through the early winload execution, but failing to start the NT kernel. The early winload execution and kernel image is identical between the installation image and a fully installed image, so even if I was able to install Windows in a GPT partition it will not boot using UEFI due to missing firmware features.

Reading the “UEFI Support and Requirements for Windows Operating Systems” document makes it clear that only UEFI 2.0 is supported.

Conclusion

Until Apple upgrades its UEFI firmware to version 2.0 or higher, Windows 7 will not natively boot on a Macintosh. Bootcamp is the only solution and Apple has little motivation to upgrade their firmware.

Links

http://technet.microsoft.com/en-us/library/dd744321(WS.10).aspx

http://support.microsoft.com/kb/947024

http://www.insanelymac.com/forum/lofiversion/index.php/t184349.html

http://technet.microsoft.com/en-us/library/dd799303(WS.10).aspx

http://refit.sourceforge.net/

http://homepages.tesco.net/J.deBoynePollard/FGA/efi-boot-process.html

http://www.felipe-alfaro.org/blog/2006/09/19/installing-refit-on-the-hidden-efi-system-partition/

http://technet.microsoft.com/en-us/library/dd744321(WS.10).aspx

http://www.microsoft.com/whdc/system/platform/firmware/uefireg.mspx

Update: 7/20/2011

It appears that with the more recent Mac systems Apple is moving to UEFI 2.0. Notably the MacBook (Mid 2010), MacBook Pro (13-inch, Mid 2010), and MacBook Air (Late 2010). Logically the 2011 versions as well?

If correct, these systems should be able to native UEFI boot Windows 7 (or Windows Server 2008 R2). Anyone have an extra machine they want to send me to test?

Eventually they may catch up with the UEFI community that has already released 2.3.1.

Useful link: http://support.apple.com/kb/HT1237

 

 

 

About these ads
This entry was posted in Computers and Internet. Bookmark the permalink.

23 Responses to Native UEFI Windows 7 Boot on Mac Mini

  1. Unknown says:

    Excellent write-up of a subject that has been mis-explained and over-explained elsewhere. I found this post, didn’t bookmark it, and wasted a lot of time trying to get Windows 7 x64 or Server 2008 R2 to install to a GPT disk.

  2. Sejong says:

    I just ran rEFIt on a Mid 2011 MacBook Air. The rEFIt shell ver command showed EFI version 1.1. This surprised me because you mentioned that recent Mas such as the Late 2010 MacBook Air were running EFI version 2.0. That’s what Apple says, but has anyone checked using rEFIt?

    Also, holding down the alt/option key when booting a Mid 2011 MacBook Air with a USB optical drive with a Windows 7 x64 DVD turns up the expected boot device icons (OS X and Windows hard disk, Windows optical disk, and EFI boot optical disk). Selecting the EFI boot icon boots the existing Windows instance, not the OS X instance, and not the Windows installer – the activity light on the optical drive comes on briefly, but the Windows installer is not booted.

    Finally, Windows can be installed from a USB stick or an SD card on a Mid 2011 MacBook Air. This is a change from older Macs, such as a Mid 2010 Mac mini, which won’t boot a Windows 7 installer from such media (but will boot an OS X Lion installer!)

  3. Razvan Vilt says:

    Actually after a long time, I finally figured out that Windows 7 installs and runs quite fine in EFI mode on a mid-2010 MacBook Pro. There is just one catch: it doesn’t understand the dual video cards.
    What you have to do is boot and install Windows 7 in UEFI mode using the UEFI DUET Package. Make a bootable CD image of UEFI DUET with mkisofs and burn it. Copy all the files from the Windows 7 x64 DVD to a FAT Formatted USB Stick. Put bootmgfw.efi on the USB stick in the EFI\BOOT folder. Rename-it as bootx64.efi.
    Boot from the UEFI DUET CD on your Mac (hold the Option Key). It will eventually boot the Windows 7 in EFI mode. Install, as you should but when the system reboots, remove the USB key and boot from the CD. Install ALL Bootcamp drivers. Do not install the Intel HD graphics driver as it will make your Windows crash on bootup.
    Set a password to your account user account.
    Enable the AHCI driver and add the SATA device to the CriticalDevicePath with the msahci driver.
    Now, you should be able to boot Windows without UEFI DUET, using the onboard EFI. It occasionally fails (under unknown circumstances).
    You will probably see nothing on the display, but Remote Desktop works like a charm.

    I haven’t yet found a decent combination of gpu-policy in the NVRAM that disables completely one of the video cards.
    Based on Ubuntu gmux details I have tried to disable video cards also using the mux. In the EFI Shell you can run “mm 750 1 -IO” just like you would run “outb 0x750 1″ in Grub.
    You can even run the commands blind, but I haven found a combination that works on the internal LCD or an externally connected display, but I’m still trying. My guess is that Windows defaults to the Intel HD video card, while the Mac is actually connected by the mux to the NVidia card.

    I figured out accidentally that Windows works in UEFI on Macs by pressing the Caps Lock key when it was locked and seeing that it actually worked. I’ve tried changing the EFI version reported by the firmware (6 lines of C code with includes) and Windows didn’t care about that. UEFI Duet also worked with EFI version 1.10 reported to Windows.

  4. Pingback: Windows 8 on a Mac: why Microsoft should write its own Boot Camp | ZDNet

  5. Pingback: Windows 8 on a Mac: why Microsoft should write its own Boot Camp - Tech News

  6. Pingback: Windows 8 on a Mac: why Microsoft should write its own Boot Camp | Webluc

  7. Not says:

    I tried this in an EFI2.0 firmware MacbookPro, but it still doesn’t work.

    The loading (in safe mode) stops/hangs after “disk.sys”.

  8. Razvan Vilt says:

    I figured it out some time ago. Macs are 100% compliant. It’s Windows that’s not. Windows tries to use int10h (VGA) for graphics display if it doesn’t have a video driver. Furthermore, Windows doesn’t set the VGAE PCI register for the main VGA card. Even if a driver is loaded, without VGAE it’s blank. We’re working on an app to fix that. The App would load before bootmgfw, set the right stuff and then chainload bootmgfw.efi. See http://forums.macrumors.com/showthread.php?t=696523&page=3

    • Razvan Vilt says:

      P.S.: The reason for which it apparently hangs is that it can’t start the video driver and you see on the frame buffer the last thing that it loaded. To test it out, try doing a 100% unattended install and see if it installs Windows in EFI mode. It worked for me on a few 64bit Macs.

    • Yuhong Bao says:

      FYI, Windows 8 removes this requirement and is able to use the UEFI GOP framebuffer.

  9. Not says:

    Thanks for the info/links.

    Yes it seems that this happens because it can’t start the video driver.

    I will wait for the bootloader-hack to be released then. Thanks.

  10. Not says:

    Update, in case it helps:

    If you set the resolution to 1024×768 (not stretched) in OSX, after restart, the pre-boot EFI environment also gets that resolution, which is compatible with Windows 7 EFI Boot.

    I can now see the Windows logo animation but still, it hangs there “animating” all the time never starting the installation itself.

    • Razvan Vilt says:

      It doesn’t work on my Laptop, but I am adding to the app mentioned on the forums an EDID Override for 1024×768. That should do the trick. I already have everything for the PCI regs and am only missing the EDID Override for PreOS and the VGA Option ROM emulation for Windows Setup and Safe Mode.
      You’re welcome to send me an email if you want to test it. Without the VGA Option ROM you need to do an unattended install with a slipstreamed video driver.

  11. Razvan Vilt says:

    Hi David,

    I’ve finished a build of the Application mentioned on the forums that makes the Windows Accelerated drivers work and chain loads Windows, if you want to give it a try. Send me an email.

    Cheers,
    R.

  12. David says:

    Any news with this problem? I tried many ways to install windows server 2008 R2 on my mac mini 2011 which has 05 processor and Lion on.

    I bought mini because of server 2008 for my college course and I have no idea what to do now. :(

    • Razvan Vilt says:

      Hi David,

      I know the problem and there are actually two of them:
      1) specific to the 2011 Mac Mini with the Intel Graphics being loaded in the EFI. You won’t be able for now to use the discrete video card. Will be solved later on, but I will need to do a bit of debuging and testing on a real 2011 Mac Mini. Till then, the Intel Graphics works correctly.
      2) The lack of the UpdateCapsule implementation in EFI which crashes the boot loader stuff in Windows.

      I am working (in my spare time) on both of them and will let you know when I solve both of them.

      Christoph came up with a work-around for the UpdateCapsule mostly documented in the MacRumors thread mentioned above.
      I came up with another simpler workaround. Get a UEFI DUET build from Tiano Core and make a bootable CD with the duet floppy image. Finish the install using CD and a Windows 2008 on a USB stick, convert to AHCI by enabling the MSAHCI service in core-services and boot straight using the EFI implementation of your Mac. It worked for me.

      Here’s a directly bootable ISO file:
      https://files.me.com/razvan.vilt/n0kaah

      The process is simple, though takes a bit of time:
      1) CSM boot the CDROM image.
      2) Tiano Core UEFI implementation starts over the emulated BIOS
      3) If you don’t want to conver to AHCI post-install, convert your IDE controller to SATA in the EFI Shell on every CDROM boot using “mm 00021f90 60 -PCI” (equivalent of “setpci 00:02:1f 90:b=60 or something like that”). This might not be the right value for your Mac but I can’t be sure.
      4) Windows installs successfully (boot from the CDROM and do the AHCI step after every reboot)
      5) Install BootCamp drivers
      6) Attempt to boot directly from EFI without using the BootCamp-ed Tiano Core implementation. It works for me in both Windows 7 and 8.

      Unattended installs currently fail at “creating BCD store” every time when Windows tries to touch the BootLoader (twice during the installation). My application will also solve that by overloading a new runtime-services implementation that adds a dummy UpdateCapsule() implementation (returns EFI_NOT_SUPPORTED everytime).

      Cheers,
      R.

      • Razvan Vilt says:

        Forgot to mention:
        You still need my application in order for the graphics to work beyond step 6. Mail me for a copy.

  13. Jason says:

    Ugg. It’s January 2013, and I’ve been reading forums nonstop for almost a week, and have learned far more than I’ve ever wanted in my quest to get Windows 7 Pro 64-bit installed on my Macbook Pro 9.2 (with UEFI 2.9) but get a freeze up after the “Windows is Loading Files…” bar whether I’m EFI booting off the Windows installation CD or whether I’m EFI booting a FAT32 formatted installation USB drive. I can’t believe we’re now into 2013 and nobody has figured this out yet! (I’m not complaining, and I appreciate all the work people have done to try and make this work) I really want to throw this macbook out the window at this point, even if the problem is really more caused by Microsoft… Has there been any developments since October 2011?

    • darobins says:

      Positive news is that Windows 8 was designed for, and in some cases requires (e.g. ARM 32-bit), UEFI to boot. It is likely that some of the issues found above with Windows 7 (graphics) have been fixed.
      Negative news is that Windows 8 requires UEFI standard 2.3.1 which is only now starting to be deployed widely. So older systems will still most likely need to boot in BIOS mode (aka CSM).
      There is still a fundamental problem that Apple is a closed system and their UEFI only needs to be good enough to boot MacOS, regardless of the standards. I am actually surprised that they haven’t adopted UEFI SecureBoot to prevent other OSes from booting.
      Lastly, the Mac firmware version string such as 2.9 is an Apple version number, and not the UEFI standard version number. You will need to boot a UEFI shell such as rEFIt to get its real capabilities.
      If I were to do this again, I would start with Windows 8 and its Windows-To-Go USB drive capability.

  14. Anon says:

    Hello darobins. Could you please look at this article and see if you can help them? https://discussions.apple.com/thread/4958786?start=15&tstart=0

  15. Brendon says:

    I’ve found some interesting reading for those wanting to know why it is so difficult/impossible to get Windows 7 working in (u)efi mode on macs as opposed to Windows 8 – Windows 7 is not fully uefi compliant.

    In the article “UEFI Support and Requirements for Windows Operating Systems”
    http://msdn.microsoft.com/en-us/libr…/gg463144.aspx it mentions that for Windows 7, “existing Windows dependencies on INT 10 video BIOS functions also require a CSM”. In its advice to firmware manufacturers, it recommends that when secure boot is disabled ie for booting versions of windows other than Windows 8 (such as Windows 7), the firmware should

    • Enable the CSM for VGA support, though not BIOS mode emulation.
    • Enable messages during the POST process to show which keys open the boot menus.

    In other words, Windows 7 still requires a “Compatibility Support Module” for video functions in its “hybrid” uefi mode.

    On macs, it is all or none: CSM is provided for video and everything else if you boot legacy BIOS emulation via bootcamp and a hybrid mbr disk. If you boot in pure (u)efi mode from a pure GPT formatted disk, no CSM is provided and hence Windows 7 uefi install hangs. Windows 8 is OK since it uses GOP for video instead of int10.

    On PCs such as Lenovo X1 Carbon described in this thread http://forums.lenovo.com/t5/X-Series…le/td-p/911353
    there is an intermediate (u)efi mode with CSM provided for video only. This allows installation of Windows 7 in (u)efi mode.

    The DaGr8Gatzby in this thread http://forums.macrumors.com/showthre…696523&page=19 described how he installed Windows 7 in efi on his Mac Pro. Note he had to go to great lengths to make it work including manually going into the efi shell and initializing PCI registers for VGA.

    I can personally confirm it is possible to install Windows 8 in efi mode on a Mac mini late 2012. Everything seems to work (including Cirrus Audio, Broadcom network wireless, Intel 4000 video and hdmi audio) after installing the latest bootcamp 5.0.5033 drivers.
    This guide http://spblinux.de/blog/2013/03/mac-…-opensuse12-3/ also describes how to setup a triple boot OSX, Windows 8 and Linux efi system on a late 2012 Mac mini

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s