Ubuntu – Sony VAIO with Insyde H2O EFI bios will not boot into GRUB EFI

grub2sonyuefi

I bought a new Sony Vaio S series laptop. It uses Insyde H2O BIOS EFI, and trying to install Linux on it is driving me crazy.

root@kubuntu:~# parted /dev/sda print
Model: ATA Hitachi HTS72756 (scsi)
Disk /dev/sda: 640GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number  Start  End    Size    File system  Name                          Flags
 1      1049kB  274MB  273MB  fat32        EFI system partition          hidden
 2      274MB  20.8GB  20.6GB  ntfs        Basic data partition          hidden, diag
 3      20.8GB  21.1GB  273MB  fat32        EFI system partition          boot
 4      21.1GB  21.3GB  134MB                Microsoft reserved partition  msftres
 5      21.3GB  342GB  320GB  ntfs        Basic data partition
 6      342GB  358GB  16.1GB  ext4        Basic data partition
 7      358GB  374GB  16.1GB  ntfs        Basic data partition
 8      374GB  640GB  266GB  ntfs        Basic data partition

What is surprising is that there are 2 EFI system partitions on the disk. The sda2 partition is a 20gb recovery partition which loads windows with a basic recovery interface. This is accessible by pressing the "ASSIST" button as opposed to the normal power button. I presume that the sda1 EFI System Partition (ESP) loads into this recovery.

The sda3 ESP has more fleshed out entries for Microsoft Windows, which actually goes into Windows 7 (as confirmed by bcdedit.exe on Windows). Ubuntu is installed on sda6, and while installation I chose sda3 as my boot partition. The installer correctly created a sda3/EFI/ubuntu/grubx64.efi application.

The real problem: for the life of me, I can't set it to be the default! I tried creating a sda3/startup.nsh which called grubx64.efi, but it didn't help — on rebooting, the system still boots into windows. I tried using efibootmgr, and that shows as it it worked:

root@kubuntu:~# efibootmgr 
BootCurrent: 0000
BootOrder: 0000,0001
Boot0000* EFI USB Device
Boot0001* Windows Boot Manager
root@kubuntu:~# efibootmgr --create --gpt --disk /dev/sda --part 3 --write-signature --label "GRUB2" --loader "\\EFI\\ubuntu\\grubx64.efi" 
BootCurrent: 0000
BootOrder: 0002,0000,0001
Boot0000* EFI USB Device
Boot0001* Windows Boot Manager
Boot0002* GRUB2
root@kubuntu:~# efibootmgr
BootCurrent: 0000
BootOrder: 0002,0000,0001
Boot0000* EFI USB Device
Boot0001* Windows Boot Manager
Boot0002* GRUB2

However, on rebooting, as you guessed, the machine rebooted directly back into Windows.

The only things I can think of are:

  1. The sda1 partition is somehow being used
  2. Overwrite /EFI/Boot/bootx64.efi and /EFI/Microsoft/Boot/bootmgfw.efi with grubx64.efi [but this seems really radical].

Can anyone please help me out? Thanks — any help is greatly appreciated, as this issue is driving me crazy!

Best Answer

  • I was eventually able to solve this. I replaced the EFI/Microsoft/boot/bootmgfw.efi with the grub64.efi. I renamed the former to bootmgfw.efi.old and used grub to add a menu option to chainload into it.

    This implies that the firmware is hardcoded to look for the microsoft windows bootloader, and does not respect efibootmgr settings, or startup.nsh. That's really terrible.

    I found out how the Sony EFI boot process works:

    1. Look in /EFI/Microsoft/Boot/fwbootmgr.efi; if present, boot it.
    2. Look in all sub-directories of /EFI/ for grubx64.efi. If present, boot it.
    3. Boot /EFI/Boot/bootx64.efi
    4. Display an error message, such as "Operating System not found".

    Under Linux, the efibootmgr tool does work, but it displays a lot of auto-generated nonsense, including the last USB drive you've used.

    Here's how I learned all this:

    1. I opened up my new machine and collapsed the Windows partition in order to install Linux and Mac side by side.
    2. I installed Ubuntu 12.10 and the installer overwrote fwbootmgr.efi, backing up the old Windows bootloader.
    3. I restored the old Windows bootloader, but couldn't boot anything except Windows.
    4. I renamed the Windows bootloader to something bogus, and then the Grub BL took over.
    5. I renamed the ubuntu directory to something else, and Grub still loaded, even though I had install rEFInd.
    6. The only way I could get rEFInd to do what I wanted was this:

    7. Move fwbootmgr.efi to its parent directory; rEFInd will still find it, and Windows won't complain that you renamed it.

    8. Rename grubx64.efi to rfgrubx64.efi or something else recognizable.
    9. Copy rEFInd from /EFI/refind to /EFI/boot, rename /EFI/refind_x64.efi to *.bak, and lastly rename /Boot/refind_x64.efi to bootx64.efi. You should now be able to boot the Windows BL or GRUB from rEFInd. I plan to upgrade my MacOS install to Clover, and load Clover from rEFInd as well.

    (Perhaps it is possible to use the Windows Boot Manager to do all this, but EeasyBCD's EFI support is still a mess in my experience. I refuse to touch it again for a while.)