domingo, março 18, 2012

Configuring for Dual Boot (BCDEDIT)

Now that we have our disk partitioned and Fedora or Ubuntu installed, let’s set up our system to boot Windows 7 or the Linux distribution. This will involve copying the Master Boot Record of our Linux boot partition to Windows 7, and using BCDEdit to create a new entry in the BCD store that will point to that file. This way Windows 7 will display a menu at boot time that will give you a choice between Windows 7 and Linux.

Boot the system again using either the GParted disk or the Ubuntu or Fedora install disk you downloaded and let’s make a mount point for the FAT32 share partition we created (I prefer using the GParted disk because it boots to a usuable state much faster than the Fedora or Ubuntu Live disk). Open a terminal and enter the following:

mkdir /mnt/share

Next, let’s mount the correct device to this directory. Recall from the GParted partitioning steps above that the FAT32 partition is located at device /dev/sda6. Note: using the FAT32 partition in this step is optional. You may chose to use another device such as a USB drive. Just make sure to mount the appropriate device. Enter the following:

mount /dev/sda6 /mnt/share

Write the first 512 bytes of our Linux boot partition to a file and copy that file to our FAT32 partition:

dd if=/dev/sda3 of=/mnt/share/linux.bin bs=512 count=1

Exit GParted now and reboot to Windows 7. Open the FAT32 partition and you should see the linux.bin file. Copy that file to the root of the Windows boot (active) partition (e.g., C:\). Next, let’s use BCDEdit to add an entry to Windows 7’s BCD store. Administrative privileges are required to use BCDEdit, so navigate to Start->All Programs->Accessories, Right-click on Command Prompt and select “Run as administrator.” Okay, now let’s start by creating an entry for our Linux distribution. Note here that you are free to choose another entry name if desired:

bcdedit /create /d “Linux” /application BOOTSECTOR

BCDEdit will return an alphanumeric identifier for this entry that I will refer to as {ID} in the remaining steps. You’ll need to replace {ID} by the actual returned identifier. An example of {ID} is {d7294d4e-9837-11de-99ac-f3f3a79e3e93}. Next, let’s specify which partition hosts a copy of the linux.bin file:

bcdedit /set {ID} device partition=c:

The path to our linux.bin file:

bcdedit /set {ID} path \linux.bin

An entry to the displayed menu at boot time:

bcdedit /displayorder {ID} /addlast

and finally, let’s specify how long the menu choices will be displayed:

bcdedit /timeout 30

That’s it! Now reboot and you will be presented with menu where you can choose to boot to Windows 7 or Linux. When you choose Linux, you’ll be taken to the GRUB menu where you can choose to continue booting your Linux distribution or return to the previous menu.

Note: Fedora users will notice that GRUB uses the hiddenmenu option by default. This requires users to hit “Esc” within 5 seconds (another Fedora GRUB default) in order to see the full GRUB menu. Not selecting Esc results in GRUB booting to the OS selected as the default in the boot loader operating system list during installation, which, in our case, should be Fedora, if the steps above were followed. If you would like to defeat the hiddenmenu option and/or change the default timeout, boot Fedora and open a terminal. Change to root and make a back up copy of /boot/grub/grub.conf Now open the original file in your favorite editor and comment out the line hiddenmenu. You can also change the timeout value to something greater than 5 (seconds). Now you when you select the Linux option from the Windows boot loader you should see the full GRUB menu with the option of selecting Fedora or Windows 7 within the timeout value you selected.

On a final note, if at any time you want to eliminate the Linux menu option simply delete the BCD store entry you created using the following command:
bcdedit /delete {ID}

Windows XP?

If you plan to dual boot using Windows XP then you will still partition and install Ubuntu or Fedora as described above (Note, however, that XP does not use a small primary partition for boot configuration data like Windows 7 does), but you won’t be needing BCDEdit. Instead, you can simply open the boot.ini file located at C:\ and add the following entry:

c:\linux.bin="Linux"

Conclusion

With a minimal amount time, the free and open source disk partitioning tool GParted, and a little command line foo, you can easily set up a system that can dual boot Windows 7 and your choice of Linux distributions.

Nenhum comentário: