Showing posts with label boot. Show all posts
Showing posts with label boot. Show all posts

Saturday, April 13, 2013

Tri-Boot Refresh - Mountain Lion, Windows 8 and Fedora 18

This post has been a long time coming. Over the course of several months I spent the odd morning here and there attempting to build a new tri-boot machine for myself. My previous machine was still running Snow Leopard, Windows 7 and Fedora 14 and in dire need of upgrading. However, I was certain that an upgrade of OS X would destroy my carefully constructed partition table, which is why I opted to build a new machine so as to be able to continue to do my job!

Now, you might be wondering why it took so long for me to implement such a system, especially as I had already been through the process once before. The delay was caused by my initial insistence on a pure EFI/GPT booting solution; I wanted all three operating systems to boot via EFI and not rely on the Mac's hybrid GPT/MSDOS partition table and legacy boot options.

The main problem that I continually encountered was successfully booting Windows 8 via EFI. I tried several methods of installing the Microsoft OS, all of which failed to produce a bootable system:

  • Booting directly off the DVD (by holding down although and selecting the "EFI" option). This resulted in the screen blanking and a spontaneous reboot before the installer even fully loaded.
  • Following a well documented process that involved partitioning the disk using a WinPE environment and installing Windows via the dism tool that's distributed as part of the Microsoft Automated Deployment Kit. While this bypassed the initial Windows Setup step routine, I still experienced a similar issue; the screen blanked, the system rebooted and booting off the Windows partition again resulted in the following message:

    The computer restarted unexpectedly or encountered and unexpected error. Windows installation cannot proceed. To install Windows, click "OK" to restart the computer, and the restart installation.

    Grabbing the minidump from the partition and parsing it through the WinDBG tool pointed the finger at the Intel integrated GPU driver igdkmd64.sys.
  • After the above discovery, I tried tweaking hardware prior to booting the operating system by issuing commands in the EFI shell provided by rEFIt. Specifically, to try and force the Nvidia GPU to be active during the initial boot. This got me a little further through the install process, but still eventually resulted in a system crash caused by the igdkmd64.sys.
  • As a final attempt, I followed a suggestion to strip out the integrated graphics drivers after deploying the OS image. However, this also proved unsuccessful, even when combining this method with the previous technique of modifying the hardware settings via EFI shell.

Even after all the above failures, I was still keen to get this triple boot implementation working, but I was finally convinced to let the idea drop when I read some notes from people who stated that audio was known not to work with Windows instances booting via EFI. Given that my primary reason for having a system that boots Windows was to play games, it would have been terrible to sacrifice audio for the sake of possible faster boot times!

The Installation Process

After I made the decision to resort to the hybrid GPT/msdos partition table method, installation was much the same as before, with a couple of extra steps to carry out during the Linux install. I'll do my best to detail the process here, in case there are any brave souls out there willing to give it a go! I shouldn't have to say this, but this is a destructive process, so be sure to back up anything important first and be aware that your mileage may very, depending on the Apple hardware you're using (my current machine is a MacBook Pro 6,2)

  1. Boot from the OS X installation media and use Disk Utility to create the following partition scheme (these sizes can obviously be varied, depending on your priorities):
    1. Size: 80GB, label: "OS X", FS Type: HFS+, journaled, case sensitive (my personal preference, the default is case insensitive)
    2. Size: 250GB, label: "WINDOWS", FS Type: msdos
    3. Size: 1.07GB (the smallest sized partition the GUI driven Disk Utility tool is able to create), label "BOOT", FS type: msdos
    4. Size: 20GB, label: "ROOT", FS type: msdos
    5. Size: 229GB (the remaining space), label: "LVM", FS type: msdos
  2. Exit Disk Utility and begin the installation, selecting the OS X partition when prompted.
  3. A dialog box will appear warning that the File Vault (probably the Full Disk Encryption mode)and the Recovery Mode will not be available; probably due to the installer not wanting to trash the complex partition scheme. Confirm you're happy to live without these features to continue the installation routine.
  4. Once OS X installed, install the rEFIt bootloader to facilitate booting the other operating systems and their installers. NB: it might take a reboot or two for the bootloader to appear.
  5. Insert the Windows 8 DVD and reboot the machine.
  6. Boot off Win 8 DVD by CD/DVD labelled "Windows". This boots the installer using the legacy/BIOS mode of the Mac.
  7. Now, it may be possible at this point to follow the usual Windows installation routine; answering questions as prompted and clicking next. However, due to all the problems I had with trusting installation Wizards, I opted to hit Fn-shift-F10 to spawn a command prompt and perform the installation manually. Technically, just shift-F10 is the necessary key-combination to bring up a command prompt, but on a Mac the function keys are by default bound to other specific purposes (volume control, screen brightness, etc.), so using the Fn (or function) key is necessary to access the regular function keys.
    1. Run Microsoft's command line partitioning tool: diskpart
    2. To be sure of the installation drive, list the available disks: list disk
    3. Select the destination drive (usually disk 0): select disk 0
    4. List the available partitions to be sure the intended destination: list partition
    5. Select the destination partition (in this case, it should be number 3): select partition 3
    6. Format the partition as NTFS: format quick fs=ntfs label=Windows
    7. Exit the partition tool: exit
    8. Change directory to the root of the X: drive. This is necessary to access the version of the Dism tool that can apply the OS image: cd \
    9. Run the Dism tool to apply the Windows 8 image (in this case, the Professional edition):
      dism /apply-image /imagefile:d:\sources\install.wim /index:1 /applydir:c:\
    10. Change directory to the root of the new installation: c:
    11. Configure the Windows boot loader: bcdboot c:\Windows /l en-gb /s c:
    12. Exit/close the command prompt.
    13. Exit/close the Windows installer, which results in the Mac rebooting.
  8. Select the icon of the Windows logo to boot into the OS and finalise the installation as per usual (configuring user accounts, etc.).
  9. Eject the Windows DVD and insert the Fedora DVD.
  10. Reboot.
  11. Select the CD/DVD icon.
  12. Once the installer has completed booting, switch to an alternative virtual console by pressing Fn+ctrl+alt+F3, as it is necessary to create the layout of your LVM volumes before continuing with the installer:
    1. Launch the LVM tool: lvm
    2. Designate the last partition on the disk as an LVM Physical Volume (PV): pvcreate /dev/sda6
    3. Create a volume group: vgcreate vg_fedora /dev/sda6
    4. Create a volume for the /tmp file system: lvcreate -L 1G -n tmp vg_fedora
    5. Create a volume for the /var file system: lvcreate -L 1G -n var vg_fedora
    6. Create a volume for the /home file system: lvcreate -L 1G -n home vg_fedora
    7. Exit the tool and return to the installer by pressing the keys Fn+alt+F7.
  13. Proceed as normal through the installation, using the previously created 20GB partition for the root (/) volume and LVM volumes for their respective mount points. One very important note: when selecting the disk for installation, be sure to not install a bootloader, as per the instructions in the Fedora manual. During my initial attempts, this would always fail and prevent the installation from completing successfully; it needs to be carried out manually post-install.
  14. Once the installer completes, allow it to reboot the system.
  15. Select the CD/DVD icon.
  16. At the Linux boot prompt, navigate to and select the rescue system option.
  17. Let the rescue system boot, detect and mount the installed instance of Fedora.
  18. Select the shell option to be dropped to the command line.
  19. Change root to the mounted install: chroot /mnt/sysimage
  20. Generate a GRUB configuration: grub-mkconfig -o /boot/grub/grub.cfg
  21. Install GRUB to the HDDs boot sector: grub2-install --recheck /dev/sda
  22. Reboot and select the penguin icon to boot into Fedora and complete the initial setup of the OS.

If you've managed to follow all these steps, hopefully you're lucky enough to possess a triple boot machine! Some noteworthy points about the the above steps and the setup as a whole are as follows:

  • If you run into a situation where either Windows or Fedora will not boot, it may be necessary to run the rEFIt sync tool. When booting it's one of the options below the available operating systems and it repairs the hybrid partition table after the use of a partitioning tool that's not aware of it's existence.
  • After installing Fedora, trying to boot Windows via rEFIt will result in the GRUB bootloader appearing! However, the Windows install is an option here, simply select it to boot the OS.
  • I found out about how to manually install GRUB by following steps I found on the Arch Linux wiki.

Feel free to sound off in the comments if you have anything to add, or you've tried the process yourself and hit a snag, I'd be happy to try and help.

Tuesday, October 19, 2010

Triple-Boot MacBook Pro: OS X, Windows 7 and Fedora 13


I have finally been able to install (and, more importantly, boot) 3 distinct operating systems on my work laptop; a MacBook Pro 3,3. I have been using my Mac in a dual-boot configuration for several years now; booting between OS X and Fedora. Being able to boot into OS X has allowed me to apply any new firmware released as part of an Apple Software Update, as well as providing a quick-booting OS for basic web browsing (less so now with the advances made in the Fedora distribution and Linux in general).

Having used Windows 7 on my home PC for some time, I decided that this would be the version of Windows that I would endeavour to install on the Mac alongside the other two operating systems. I've found Windows 7 to be a great improvement over Vista and, dare I say it, actually an enjoyable desktop OS to use. Of course, Windows 7 would also allow me to fully partake in any gaming sessions that I happened upon while I had my laptop! However, the most compelling reason to get my Mac triple-booting was to learn more about GPT, EFI and the boot process in general on an EFI-based system.

Obviously, the first step I took was to ensure I had a recent backup of all the important data from my machine, as I would be completely trashing the existing partition table. Once I had done this, I began the installation of the first operating system.

OS X


I inserted the Snow Leopard installation DVD into the machine and booted from it. From the installer, I accessed the Disk Utility and created a new GPT partition scheme consisting of 4 partitions (well, technically 5, see below for further details):
  1. OS X: 90GB, HFS+, Journaled and Case-Sensitive

  2. WIN7: 120GB, MSDOS

  3. LINUX: 3GB, MSDOS

  4. LVM: Remaining Space, MSDOS

I then exited Disk Utility and continued with the installation of the operating system, directing the installer to use the "OS X" partition.

Windows 7


As the laptop uses an Intel Core 2 Duo CPU, I opted to install the 64bit version of Windows 7 Professional. When choosing where to install the operating system, the partitioning tool displayed a rather different view to the OS X Disk Utility; a small FAT partition (used by EFI) was positioned in front of the OS X partition, while some of the drive was marked as unallocated space. I carefully selected the 3rd partition, confirming I had the correct one by looking at it's label (WIN7) and size (approximately 120GB), and formatted it using the "Advanced" features of the partitioning tool. This is a necessary step, as the OS X Disk Utility formats the file system as FAT32 and Windows 7 requires NTFS. After this, I proceeded to select the partition I had just formatted and installed the OS.
During the installation process, the machine had to reboot, which meant I had to ensure that it booted from the Windows 7 partition in order to complete the install. On a Mac, this is accomplished by holding down the "alt" key on the keyboard when the system first boots. It causes a basic boot manager to eventually be displayed, where you can select which of the installed operating systems to boot.

Fedora 13


Finally, I booted off the Fedora 13 installation disc (again, opting for the 64bit release). When I was presented with the partitioning tool, I found I had to manually format the 4th partition as ext3 and the 5th partition as an LVM physical volume using the command line. This involved switching to another virtual console, which on a Mac requires you to hold down the "fn" and "alt" keys and press "F2". From here, it is possible to use the mkfs.ext3 and lvm command line tools to format /dev/sda4 partition, create an LVM physical volume on /dev/sda5, a volume group and some volumes.
Again, I had to be wary of choosing the wrong partitions because, as with the Windows 7 installation, the tools displayed a more complicated view of the partition table; the EFI partition and un-partitioned space were visible.
Once I had finished on the command line, I switched back to the graphical installer ("fn", "alt" and "F7") and instructed the partition manager to use /dev/sda4 as the root partition and the newly created LVM volumes for /usr, /tmp, /var, /home and swap. It's important to note that I didn't define a separate /boot partition; this is because I wanted to keep the partition scheme as simple as possible, see below for details.
When the installer reached the stage where you define where GRUB should be installed, I found that the suggested default option was what I needed; /dev/sda4. This is different to a more vanilla install of Fedora, where you would usually install GRUB to the Master Boot Record (MBR); here, there is no MBR to install to as the partition scheme is GPT.

Final Steps

After the Fedora installation completed, I rebooted into OS X (by simply not pressing anything when the machine initially boots) and installed rEFIt. This appears to be the only bootloader that would allow me to boot all three installed operating systems. I had to run the rEFIt partitioning tool before this was possible however; accessible when rEFIt loads at boot-time. This performs the necessary magic that syncs the hybrid GPT/MBR partition table, allowing each OS to boot correctly. I had to perform one final restart of the machine, which is another option in the rEFIt bootloader, and then my triple-boot Mac was complete; apart from all the subsequent OS updates and configuration, of course!

Troubles Encountered and Lessons Learnt

As mentioned previously, this install procedure took me several attempts to get right. I tried using boot camp originally, but soon found that it added unnecessary complexity to the partitioning process. I also found some guides that demonstrated methods for partitioning the disc using the Disk Utility in OS X, but this assumed an existing OS X installation was present on the system. However, as this second approach mentioned the use of Disk Utility, I assumed that using this tool to create the partition scheme for all the operating systems would work; and I was correct!

While on the subject of partitioning, I did end up discovering exactly how the hybrid GPT/MBR partition table works. OS X itself requires a GPT partition scheme; it simply refuses to install to any MBR-style disk. However, Windows requires an MBR partition scheme to boot from and will refuse to install into a partition that it believes resides on a GPT formatted disk.

The hybrid GPT/MBR scheme allows the first 4 partitions of the GPT scheme to be used as an MBR-style disk. However, it is not possible for one of these partitions to be created as an extended partition. On a pure MBR disk, you are restricted to defining 4 primary partitions. One of these can be used to hold further logical partitions, which allows for more complicated partition schemes (i.e. more than 4 partitions).

Because GPT does not allow for extended and logical partitions to be defined, a hybrid implementation limits the MBR scheme to 4 primary partitions. On top of that, because we're booting an EFI based system, there is a hidden FAT32 partition at the beginning of the disk where boot configuration is stored. This brings the total number of MBR partitions available for operating systems to 3; hence why my 2nd, 3rd and 4th partitions are used by OS X, Windows 7 and Fedora's root/boot file systems respectively. Theoretically, it should be possible to install a Linux distribution into higher numbered partitions, however the GRUB boot loader used by Fedora only understands MBR, not GPT. In order to maintain some file system organisation, I created the 5th partition as an LVM logical volume, bringing all the flexibility of resizeable volumes to the Fedora install.

The other major issue encountered was actually booting off the Windows 7 install DVD. I had sourced a copy of Windows 7 Professional 64bit from the Microsoft Partner program site; which resulted in a rather large ISO image being downloaded to my machine. After burning this to DVD and attempting to boot off the disc, I found I was unable to progress past what appeared to be a broken boot menu. There were 2 options, however, both were lacking any explanation as to what it was I would be booting into! On top of that, neither option appeared to want to boot, and I was left with the impression that the system had actually crashed.

I did some research and found that the problem because of the way the image was mastered. Apparently, some important component used in the boot process is not able to handle files that conform to the ISO 9660 standard; specifically, version numbers being appended to the file name.

This made it necessary to re-master the provided image and burn it with some rather specific settings; the most important seemed to be force the omission of the version numbers (see the previously linked blog post for further details). Once I did this, the laptop booted from the disc perfectly.

Overall, I'm very pleased with the fruits of my labour. The real test will be to see if I can replicate the results on another machine.