Tuesday, January 19, 2010

How to use Windows 7 to dual boot Windows 7/Ubuntu

It's relatively easy to use the grub of Ubuntu to dual boot Windows 7 and Ubuntu. How about using the boot loader of Windows 7 for dual boot?

  1. Make sure the grub of your Ubuntu is installed in the root partition of Ubuntu (in my case it's /dev/sda3, which can be found out by "sudo fdisk -l") instead of the MBR.

    If you already have the Grub installed on MBR or you have lost the MBR because of installing Windows, here is what you can do after you boot into the Ubuntu 9.10 LiveCD.

    sudo mkdir /tmp/ubuntu910

    sudo mount /dev/sda3 /tmp/ubuntu910

    sudo mount --bind /dev /tmp/ubuntu910/dev

    sudo chroot /tmp/ubuntu910

    sudo grub-install /dev/sda3


  2. Obtain the boot loader information of your Ubuntu.

    When you are still in the LiveCD session, type the following commands (here /dev/sda7 is the common partition in my computer that can be seen in both Windows and Linux):

    sudo mkdir /tmp/data

    sudo mount /dev/sda7 /tmp/data

    sudo dd if=/dev/sda3 of=/tmp/data/linux.bin bs=512 count=1


  3. Add the entry of Ubuntu to the boot loader of Windows 7.

    In Windows 7, first copy the file "linux.bin" from the common partition to C:\, then open a command window as "administrator", and type the following commands:

    bcdedit /create /d "Ubuntu 9.10 64bit" /application BOOTSECTOR

    bcdedit /set {ID} device partition=c:

    bcdedit /set {ID} path \linux.bin

    bcdedit /displayorder {ID} /addlast

    bcdedit /timeout 6

    Later if you want to change the name of the Ubuntu in the list, you can always do

    bcdedit /set {ID} description "Ubuntu 10.04 64bit"

No comments:

Visitors