Lenovo UEFI dual boot Windows7 Ubuntu

Today I had a real brainfuck, how to make Ubuntu and Windows 7 to coexist on my Lenovo Z570.
First I try grub-efi

 convert EFI partition to Fat32
 mount /dev/sda1 /boot/efi
 grub install /dev/sda
 
 mkdir /boot/efi/efi/boot/
 cp /boot/efi/efi/debian/grubx64.efi /boot/efi/efi/boot/bootx64.efi

Gentoo booting O.k., but I cannot make Windows 7 boot.
I copy windows loader efi from Windows/Boot/EFI And BCD (data for loader) at the same folder, and try custom menuitem at grub
It looks like this

menuentry "Win7" --class windows --class os {
  insmod part_msdos
  insmod fat
  set root '(hd0,msdos1)'
  search --no-floppy --fs-uuid --set root MY_UUID_FS
  chainloader $({root})/EFI/Microsoft/BOOT/bootmgfw.efi
}

Damn it`s not working. I`m talking about this wrong ways for you not to try this.

The only way how i make dual boot working.

1. Replace grub-efi with grub-pc (non efi grub build)
aptitude update && aptitude install grub-pc
2. install grub to linux partition my – /dev/sda6
3. Make it boot from Windows loader.

There is 2 way how to make it boot from Windows loader.
1. Use easybcd. (this will install grub4dos fork or other grub fork to load ubuntu from /dev/sda6)
2. Use windows native loader. Here are instructions for Windows 7 (there is no boot.ini at windows7 BCD used instead)

dd if=/dev/sda6 of=/mnt/share/linux.bin bs=512 count=1
bcdedit /create /d “Ubuntu” /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

It`s working! Now I have dual boot at this UEFI damned notebook!

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>