wombathuffer
November 30th, 2009, 09:45 PM
Dual boot bcdedit (Windows 7 bootloader) into GRUB
So - it happened that I decided to run windows 7 on the first two partitions of my disk and Ubuntu 9.10 on the rest.
After a neat and tidy windows install with everything working, I installed the Karmic Koala with everything working.. Booting back into Windows to install some software from my DVD-Drive, and *poof*, it disappeared - gone and no sign of it in the device manager.
I spend a week or so, trying to collect drivers to my TSSTCorp CD/DVD-drive on my Zepto 66W25WD with an Intel ICH8M chipset, and installing the Windows 7 beta again and rebooting into Ubuntu to compare the driver data..
Then I reinstalled windows 7 and ran all them windows updates, and the DVD-drive was still present there..
YAY its working! Lets get cracking and reinstall grub!
...or not - when grub was reinstalled, my CD-drive disappeared again.
CONCLUSION: (tadaaa!!!)
The Famous GRUB-bootloader is making my CD/DVD-drive invisible.
There got to be some settings in Windows 7s own boot manager, which implies to the ATAPI-controller.
okay - it seemed that I was stuck..
Got Ubuntu installed and I cant use grub... Great! Lets bring a windows DVD and a Ubuntu-CD around with my laptop, in case I want to install something from a DVD on windows... NOT!
I read a sh'tload of post concerning a regedit, removing keys for upper- lower filters in a regedit class, in windows, but as Murpheys law dictates, I didn't have the upper- lower filter keys to delete.
SOLUTION:
I wanted to keep my ******* 7 MBR, and boot into grub.
So when I got my windows 7 mbr without any ubuntu-options, I booted the Ubuntu CD and as I still got a working menu.lst (or grub.cfg in my case) in /boot/grub of my Ubuntu-partition, I did:
sudo -i(stay in root and recheck your future commands for typos before you hit enter!)
mkdir /media/tmp(make a folder called /media/tmp)
mount /dev/sda5 /media/tmp(mount my Ubuntu /root partition into /media/tmp)
grub-install --root-directory=/media/tmp /dev/sda(install grub with /media/tmp as root / on the MBR of /dev/sda)
And then I rebooted...
And there was much rejoice as grub was working again. YAY!
Then I booted my Ubuntu on my hdd, and found my two windows 7-drives (first one is the boot-partition second is the system-partition):
ls -al /media/some-disk-idand
ls -al /media/System Reserved(I mounted my Windows system-drive into /media/win7 which I will refer to, further on..)
(if the /media-folders for windows, are not there, find out where they are, with
sudo fdisk -land mount them with
sudo mount /dev/sdaX /media/folder-of-own-choise.)
Then I dumped the grub-mbr into a bin file with the following command:
sudo dd if=/dev/sda of=/media/win7/ubuntu.bin bs=448 count=1(dd the mbr from /dev/sda into the file /media/win7/ubuntu.bin and only the first 448 bytes of the MBR.
Why 448? MBR consists of 512 bytes, 448 bytes for the bootstrap and 64 bytes for the partition table, and as we only need the bootstrap we set bs=448)
I wasn't sure where windows is gonna look for the bin-file so I copied it to the win 7 boot-partition aswel:
cp -rf /media/win7/ubuntu.bin /media/System ReservedWith this bin file written, I rebooted and entered windows 7 in the grub menu (with my CD-drive not working, remember?)
Then I read up on the bcdedit-tool for customising the windows bootloader and did the following in a cmd run as an administrator:
bcdedit /enum(Shows the OS the windows bootloader can see at the moment.)
bcdedit /create /d "GRUB" /Application BOOTSECTOR(Create a new entry in the Windows boot menu, and call it Grub and look in the bootsector for further instructions.)
In return I got some kind of diskID, in my case: {f16e7bd4-dd5b-11de-80c1-e83d58bc56bc}
bcdedit /set {f16e7bd4-dd5b-11de-80c1-e83d58bc56bc} device boot(Tells the bootloader to look for the bootstrap-information for grub on the Boot-partition.)
bcdedit /set {f16e7bd4-dd5b-11de-80c1-e83d58bc56bc} PATH \ubuntu.bin(continue to tell the bootloader that the bootstrap info is in \ubuntu.bin)
bcdedit /displayorder {f16e7bd4-dd5b-11de-80c1-e83d58bc56bc} /addlast(Showing GRUB as the last choice in the windows boot menu)
OPTIONAL:
bcdedit /timeout 10(as I really dont have the patience to wait 30 sec when booting)
Then I rebooted to test the menu, and it smoothly went to the grub menu, and when choosing Windows 7 in the grub menu, it went straight into the Windows-menu, where I could choose between windows 7 and GRUB.
I tested a few times that I both could boot Ubuntu and Windows, and when I was sure it worked as intended, I rebooted the Windows DVD, and installed the windows MBR from the command prompt on the Windows DVD, (when booting from it, entering "Repair" on the Windows 7 DVD) by doing:
BootRec.exe /fixmbrand rebooted...
Now I got the windows 7 bootmanager first with a working visible DVD-drive in windows 7 and a second option, redirecting me to the grub boot menu with Ubuntu 9.10.
If anyone is interested I have posted the output of bcdedit /enum from windows:
Windows Boot Manager
--------------------
identifier {bootmgr}
device partition=\Device\HarddiskVolume1
description Windows Boot Manager
locale da-DK
inherit {globalsettings}
default {current}
resumeobject {f16e7bd5-dd5b-11de-80c1-e83d58bc56bc}
displayorder {current}
{f16e7bd4-dd5b-11de-80c1-e83d58bc56bc}
toolsdisplayorder {memdiag}
timeout 5
Windows Boot Loader
-------------------
identifier {current}
device partition=C:
path \Windows\system32\winload.exe
description Windows 7
locale da-DK
inherit {bootloadersettings}
osdevice partition=C:
systemroot \Windows
resumeobject {f16e7bd5-dd5b-11de-80c1-e83d58bc56bc}
nx OptIn
detecthal Yes
Real-mode Boot Sector
---------------------
identifier {f16e7bd4-dd5b-11de-80c1-e83d58bc56bc}
device boot
path \ubuntu.bin
description GRUB
and the menu.lst (mine is grub.cfg):
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
if [ -s /boot/grub/grubenv ]; then
have_grubenv=true
load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
saved_entry=${prev_saved_entry}
save_env saved_entry
prev_saved_entry=
save_env prev_saved_entry
fi
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set 5520d8ae-dc51-4339-9e46-2afbe5bd06ab
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=1600x1200
insmod gfxterm
insmod vbe
if terminal_output gfxterm ; then true ; else
# For backward compatibility with versions of terminal.mod that don't
# understand terminal_output
terminal gfxterm
fi
fi
if [ ${recordfail} = 1 ]; then
set timeout=-1
else
set timeout=10
fi
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/white
### END /etc/grub.d/05_debian_theme ###
### BEGIN /etc/grub.d/10_linux ###
menuentry "Ubuntu, Linux 2.6.31-14-generic" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
set quiet=1
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set 5520d8ae-dc51-4339-9e46-2afbe5bd06ab
linux /boot/vmlinuz-2.6.31-14-generic pci=noacpi root=UUID=5520d8ae-dc51-4339-9e46-2afbe5bd06ab ro splash vga=799 quiet splash acpi=off
initrd /boot/initrd.img-2.6.31-14-generic
}
menuentry "Ubuntu, Linux 2.6.31-14-generic (recovery mode)" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set 5520d8ae-dc51-4339-9e46-2afbe5bd06ab
linux /boot/vmlinuz-2.6.31-14-generic pci=noacpi root=UUID=5520d8ae-dc51-4339-9e46-2afbe5bd06ab ro single splash vga=799 acpi=off
initrd /boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###
### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows 7 (loader) (on /dev/sda1)" {
insmod ntfs
set root=(hd0,1)
search --no-floppy --fs-uuid --set 16BA2FD4BA2FAEE5
chainloader +1
}
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###
So - it happened that I decided to run windows 7 on the first two partitions of my disk and Ubuntu 9.10 on the rest.
After a neat and tidy windows install with everything working, I installed the Karmic Koala with everything working.. Booting back into Windows to install some software from my DVD-Drive, and *poof*, it disappeared - gone and no sign of it in the device manager.
I spend a week or so, trying to collect drivers to my TSSTCorp CD/DVD-drive on my Zepto 66W25WD with an Intel ICH8M chipset, and installing the Windows 7 beta again and rebooting into Ubuntu to compare the driver data..
Then I reinstalled windows 7 and ran all them windows updates, and the DVD-drive was still present there..
YAY its working! Lets get cracking and reinstall grub!
...or not - when grub was reinstalled, my CD-drive disappeared again.
CONCLUSION: (tadaaa!!!)
The Famous GRUB-bootloader is making my CD/DVD-drive invisible.
There got to be some settings in Windows 7s own boot manager, which implies to the ATAPI-controller.
okay - it seemed that I was stuck..
Got Ubuntu installed and I cant use grub... Great! Lets bring a windows DVD and a Ubuntu-CD around with my laptop, in case I want to install something from a DVD on windows... NOT!
I read a sh'tload of post concerning a regedit, removing keys for upper- lower filters in a regedit class, in windows, but as Murpheys law dictates, I didn't have the upper- lower filter keys to delete.
SOLUTION:
I wanted to keep my ******* 7 MBR, and boot into grub.
So when I got my windows 7 mbr without any ubuntu-options, I booted the Ubuntu CD and as I still got a working menu.lst (or grub.cfg in my case) in /boot/grub of my Ubuntu-partition, I did:
sudo -i(stay in root and recheck your future commands for typos before you hit enter!)
mkdir /media/tmp(make a folder called /media/tmp)
mount /dev/sda5 /media/tmp(mount my Ubuntu /root partition into /media/tmp)
grub-install --root-directory=/media/tmp /dev/sda(install grub with /media/tmp as root / on the MBR of /dev/sda)
And then I rebooted...
And there was much rejoice as grub was working again. YAY!
Then I booted my Ubuntu on my hdd, and found my two windows 7-drives (first one is the boot-partition second is the system-partition):
ls -al /media/some-disk-idand
ls -al /media/System Reserved(I mounted my Windows system-drive into /media/win7 which I will refer to, further on..)
(if the /media-folders for windows, are not there, find out where they are, with
sudo fdisk -land mount them with
sudo mount /dev/sdaX /media/folder-of-own-choise.)
Then I dumped the grub-mbr into a bin file with the following command:
sudo dd if=/dev/sda of=/media/win7/ubuntu.bin bs=448 count=1(dd the mbr from /dev/sda into the file /media/win7/ubuntu.bin and only the first 448 bytes of the MBR.
Why 448? MBR consists of 512 bytes, 448 bytes for the bootstrap and 64 bytes for the partition table, and as we only need the bootstrap we set bs=448)
I wasn't sure where windows is gonna look for the bin-file so I copied it to the win 7 boot-partition aswel:
cp -rf /media/win7/ubuntu.bin /media/System ReservedWith this bin file written, I rebooted and entered windows 7 in the grub menu (with my CD-drive not working, remember?)
Then I read up on the bcdedit-tool for customising the windows bootloader and did the following in a cmd run as an administrator:
bcdedit /enum(Shows the OS the windows bootloader can see at the moment.)
bcdedit /create /d "GRUB" /Application BOOTSECTOR(Create a new entry in the Windows boot menu, and call it Grub and look in the bootsector for further instructions.)
In return I got some kind of diskID, in my case: {f16e7bd4-dd5b-11de-80c1-e83d58bc56bc}
bcdedit /set {f16e7bd4-dd5b-11de-80c1-e83d58bc56bc} device boot(Tells the bootloader to look for the bootstrap-information for grub on the Boot-partition.)
bcdedit /set {f16e7bd4-dd5b-11de-80c1-e83d58bc56bc} PATH \ubuntu.bin(continue to tell the bootloader that the bootstrap info is in \ubuntu.bin)
bcdedit /displayorder {f16e7bd4-dd5b-11de-80c1-e83d58bc56bc} /addlast(Showing GRUB as the last choice in the windows boot menu)
OPTIONAL:
bcdedit /timeout 10(as I really dont have the patience to wait 30 sec when booting)
Then I rebooted to test the menu, and it smoothly went to the grub menu, and when choosing Windows 7 in the grub menu, it went straight into the Windows-menu, where I could choose between windows 7 and GRUB.
I tested a few times that I both could boot Ubuntu and Windows, and when I was sure it worked as intended, I rebooted the Windows DVD, and installed the windows MBR from the command prompt on the Windows DVD, (when booting from it, entering "Repair" on the Windows 7 DVD) by doing:
BootRec.exe /fixmbrand rebooted...
Now I got the windows 7 bootmanager first with a working visible DVD-drive in windows 7 and a second option, redirecting me to the grub boot menu with Ubuntu 9.10.
If anyone is interested I have posted the output of bcdedit /enum from windows:
Windows Boot Manager
--------------------
identifier {bootmgr}
device partition=\Device\HarddiskVolume1
description Windows Boot Manager
locale da-DK
inherit {globalsettings}
default {current}
resumeobject {f16e7bd5-dd5b-11de-80c1-e83d58bc56bc}
displayorder {current}
{f16e7bd4-dd5b-11de-80c1-e83d58bc56bc}
toolsdisplayorder {memdiag}
timeout 5
Windows Boot Loader
-------------------
identifier {current}
device partition=C:
path \Windows\system32\winload.exe
description Windows 7
locale da-DK
inherit {bootloadersettings}
osdevice partition=C:
systemroot \Windows
resumeobject {f16e7bd5-dd5b-11de-80c1-e83d58bc56bc}
nx OptIn
detecthal Yes
Real-mode Boot Sector
---------------------
identifier {f16e7bd4-dd5b-11de-80c1-e83d58bc56bc}
device boot
path \ubuntu.bin
description GRUB
and the menu.lst (mine is grub.cfg):
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
if [ -s /boot/grub/grubenv ]; then
have_grubenv=true
load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
saved_entry=${prev_saved_entry}
save_env saved_entry
prev_saved_entry=
save_env prev_saved_entry
fi
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set 5520d8ae-dc51-4339-9e46-2afbe5bd06ab
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=1600x1200
insmod gfxterm
insmod vbe
if terminal_output gfxterm ; then true ; else
# For backward compatibility with versions of terminal.mod that don't
# understand terminal_output
terminal gfxterm
fi
fi
if [ ${recordfail} = 1 ]; then
set timeout=-1
else
set timeout=10
fi
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/white
### END /etc/grub.d/05_debian_theme ###
### BEGIN /etc/grub.d/10_linux ###
menuentry "Ubuntu, Linux 2.6.31-14-generic" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
set quiet=1
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set 5520d8ae-dc51-4339-9e46-2afbe5bd06ab
linux /boot/vmlinuz-2.6.31-14-generic pci=noacpi root=UUID=5520d8ae-dc51-4339-9e46-2afbe5bd06ab ro splash vga=799 quiet splash acpi=off
initrd /boot/initrd.img-2.6.31-14-generic
}
menuentry "Ubuntu, Linux 2.6.31-14-generic (recovery mode)" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set 5520d8ae-dc51-4339-9e46-2afbe5bd06ab
linux /boot/vmlinuz-2.6.31-14-generic pci=noacpi root=UUID=5520d8ae-dc51-4339-9e46-2afbe5bd06ab ro single splash vga=799 acpi=off
initrd /boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###
### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows 7 (loader) (on /dev/sda1)" {
insmod ntfs
set root=(hd0,1)
search --no-floppy --fs-uuid --set 16BA2FD4BA2FAEE5
chainloader +1
}
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###