So, here's the story...
An HP laptop with Windows 7 and Ubuntu 12.04 (Precise Pangolin) dual-booted by GRUB2 is the central character. My friend handed me over saying that one fine morning 'she' found it to boot directly to Windows 7 without offering the usual OS selection (Windows 7, Ubuntu 12.04) menu. Also she was confident that she did absolutely "nothing" which could the reason be. With my limited knowledge, unless at least a single bit changes on HD, it is impossible. Promising to try to fix it up, I turned the laptop on. To my desperation, I found it to be one with stupid UEFI firmware. Pressing F9 leads to one firmware menu listing out EFI boot images. Ubuntu was present there. Selecting that one could boot Ubuntu as usual. From within Ubuntu, I tried using fdisk -l and was reported that fdisk was unable to read GPT partition table. So, I used GParted instead. There was one EFI partition of ~400MB as usual. That partition gets automatically mounted under /boot. Examining the contents inside, I found nothing unusual. AFAICR, it should be a VFAT filesystem. Also first 446 bytes of MBR was zero-filled. I googled and found something 'magical' called efibootmgr, the magic wand to play with EFI system. Now, the pain begins.
efibootmgr -v prints out the EFI boot images where both Windows 7 and Ubuntu were there alongwith other options, as expected.
efibootmgr -n switch is supposed to change the default boot loader for the next boot ONLY. I set BootNext field to Ubuntu and GRUB2 menu appeared in the next boot!
efibootmgr -o X, Y switch is supposed to change the default boot loader permanently. Delighted with the previous success, I changed the boot order Ubuntu follwed by Windows 7. efibootmgr -v confirmed that the changes took place as expected. But, to my surprise, laptop booted to Windows 7 directly on next boot!!!
Thereafter, I did a lot of tinkering with the laptop with no success. I tried using bcdedit, EasyBCD etc. and even more which I am too lazy to type unless asked specifically. All the attempts were in vain. Suddenly, I got this google hit
Issue #1 On HP laptop I cannot change the default boot OS in the BIOS, But when I used the F9 option at boot I can boot to ubuntu.
Issue #2 When I use efibootmgr -o command as seen below to change the boot order. During boot the laptop revert back to the the old boot order before the change. interstingly the -n option works (i,e modify boot order for the next boot only). I would like to avoid placing efibootmgr -n ... in my rc.local.
Any idea how to make efibootmgr change the boot order permanently? Since the laptop was dual-booting earlier, so there must be "something" to bypass this quirk.