Booting Ubuntu Karmic and Windows 7 from a GPT partition using BIOS

Those are some notes taken while trying to get this setup running. I’ve actually been running this for a long time, and so the post has have been in draft status far too long. I needed to finish it up before my memory would fail me.

The roadblocks here are mainly related to weak support for GPT. Windows up to at least version 7 can only boot from GPT when EFI is also used, and some of the Linux tools also have the one or other quirk when dealing with GPT (note that I was using Karmic; Lucid may not have some of the problems).

  • Create your GPT based partitions using gparted from an Ubuntu Live CD.
    • Make sure your Windows partition is first, or at least one of the first three.
    • Create a 1MB partition with the bios_grub flag. This is what the guided Ubuntu installer would do, and it’s required by grub to boot from GPT. gparted apparently enforces a minimum partition size of 8 megabytes, which should be find too, if wholly unnecessary, but I used parted to get to just one megabyte. I choose ext2 as the filesystem type, but I don’t think it matters.
  • In case you want to encrypt your root-filesystem: Make sure you have /boot on a separate, unencrypted partition.
  • Use gptsync to write out a Hybrid-MBR based on your GPT. This is required to make Windows boot. This is also why Windows needs to be one of the first three partitions. Further GPT partitions will not fit into the MBR. Note that for all I can tell, once Windows is booted, you can access your full GPT disc just fine.
    • If gptsync has problems with “unknown” partitions, try with a newer .deb from the Debian repositories.
    • Important: At this point, don’t touch your GPT partition table except with tools that can properly deal with Hybrid-MBRs. Unfortunately, that doesn’t include gparted, which will clear out the Hybrid-MBR. In this case, you have to run gptsync again.
  • Use fdisk to change partition type id of your Windows 7 partition to HPFS/NTFS (hex 7). If it hasn’t the proper id, Windows setup will refuse to install on it. When I tried to fix that by recreating the partition through the Windows installer, it ended up with slightly different LBA bounds than before (i.e. resulting in mismatch to the GPT table). So, do this now.
  • Install Windows.
  • Install Karmic. grub2 should pick up the Windows installation automatically (this is done by checking for a Boot/BCD file. If your Windows install isn’t found, you might want to look at /usr/lib/os-probes/ to find out why).

If you ever need to rewrite grub2, maybe cause you reinstalled Windows, you can boot into an Ubuntu Live CD and do:

# If you are using encryption, open the root partition
$ cryptsetup ...
# If you are using LVM, it might be necessary to make the partition available
$ lvchange ...

# Setup a chroot
$ mount $ROOT_PARTITION /mnt
$ mount $BOOT_PARTITION /mnt/boot
$ mount -o bind /dev /mnt/dev
$ mount -t proc proc /mnt/proc
$ mount -t sysfs sys /mnt/sys
$ chroot /mnt

# Update grub2's data (runs the os-prober, for example)
$ update-grub2
# Install the actual boot loader code
$ grub2-install /your/disk

4 thoughts on “Booting Ubuntu Karmic and Windows 7 from a GPT partition using BIOS

  1. My plan is to have separate home and root partition for ubuntu 11.04 x64(Natty Narwhal) with Windows 7 x64 and MAC OS X(if possible). Among which Ubuntu get new edition twice in a year. Please let me know the best sequence to have for this.

    Thanks in advance


  2. I want to do something similar in terms of Multi booting on BIOS based machine:
    – Win 7 x64
    – Mac OSX Snow Leopard / Lion – 64
    – Linux (Some x64 flavor)

    Eshant – Any luck ? Do share your experiences please?


Leave a Reply

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

You are commenting using your 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