When I create a Windows / Linux dual-boot computer I usually add Windows as an option to my LILO boot menu. That is the easiest way, and works always.

However, I ran into a situation where I could not use LILO as the primary boot loader and I had to look into the Windows7 “boot configuration data” or BCD. Actually it was Windows Vista, not Windows7, which was the first to abandon good old C:\boot.ini and start writing its bootloader configuration into a binary block of data. I wrote this post just to have this procedure available as a reference.

Windows7 contains the command-line program BCDedit which you are supposed to use for editing your Windows boot menu. A total load of crock it is. It will not support any OS that does not boot from the same hard disk that Windows7 is installed to… so I had some issues getting my Slackware added to the Windows boot menu because I had installed it on a second hard disk.

In the end I decided to shrink the Windows partition a little bit and add a small Linux partition where I could install LILO.

Microsoft has added a basic partition manager to Windows7 – something they do more often. If a 3rd party creates an invaluable add-on to provide functionality Microsoft did not include into Windows, then Microsoft will eventually copy its basic functionality into a half-hearted clone. Anyway, the freed-up hard disk space was allocated to a small partition which became Slackware’s “/boot” and I installed LILO to that /boot partition.

Then, just like in the days of Windows NT and “c:\boot.ini”, I extracted the first 512 bytes from the root sector of that /boot partition (in my case, that partition was “/dev/sda3“) and wrote it to a USB stick which I had mounted on “/mnt/hd“:

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

Rebooted to Windows7 and transfered that 512 byte file called “linux.bin” from the USB stick to the root of the Windows C: drive.

Next, I used BCDedit to add an entry to Windows7’s BCD store. Note that administrative privileges are required to use BCDedit!. What you do is navigate to “Start->All Programs->Accessories“, Right-click on “Command Prompt” and select “Run as administrator“.

In this command window, enter the BCDedit commands. Start by creating an entry for Slackware Linux. I use “Linux” as the label for the boot menu. The actual label you choose is arbitrary of course:

bcdedit /create /d “Linux” /application BOOTSECTOR

BCDedit will return an alphanumeric identifier for this entry. Copy that string into a text file and do not lose it!

In the remainder of this article I will refer to this string as {ID}. You would replace {ID} with the actual identifier as returned by the command you ran. An example of what you can get for an {ID} is {244ebca6-432f-11df-ab86-ce0c22f636af}.

The next step will be to specify which partition holds the copy of the Linux boot loader sector (our “linux.bin” file):

bcdedit /set {ID} device partition=c:

Then specify the actual path to the “linux.bin” file on that C: drive:

bcdedit /set {ID}  path \linux.bin

The Windows boot menu needs an entry for our Slackware Linux OS:

bcdedit /displayorder {ID} /addlast

Usually you won’t see the boot menu at all (after all, it does not contain any other entry than Windows7 itself). In order to allow the user of the computer some reflection time, we add a delay to the menu’s display timeout. Say, the boot menu should remain visible for 30 seconds before booting into the default selection:

bcdedit /timeout 30

That would be all. You can test the new Windows boot menu by rebooting the computer. You should be able to select either Windows7 (default) or Linux to boot into. When you choose “Linux”, you’ll be taken to Slackware’s familiar LILO menu.

If at any time you would have to remove the “Linux” menu option, you can run the following command … provided you wrote the {ID} string down somewhere:

bcdedit /delete {ID}

Have fun, even with Windows,

Eric