1

Recently installed Ubuntu 15.04 on my laptop alongside Windows 7. It was installed on a partition on a Samsung SSD and everything seemed to install fine. The partitions seem correct and everything looks good but for some reason when I boot the computer it boots directly into Windows without loading the GRUB menu.

I have tried the Boot-Repair tool from the Live CD a number of times and this hasn't resolved this issue. I have also tried some of the manual fixes using the terminal as suggested online but that hasn't worked either. I am new to Ubuntu as this is my first install and I am looking for some help.

I really like Ubuntu and I am pretty familiar with Linux commands so I am not a complete beginner but I do need some help figuring out how to set my system up correctly.

The Boot Info Summary for my current setup can be found here

Thanks for any help in advance.

9
  • Have you tried to deactivate the fast boot option from the Bios?
    – anarchy894
    Jul 10, 2015 at 1:16
  • Did you try the steps at the end of the Boot Info Summary? Jul 10, 2015 at 1:46
  • If by that you mean the step that adds the Ubuntu boot file to the Windows boot manager using the command prompt then yes. I tried that and it didn't change anything. And I don't even have an option to boot Ubuntu from the BIOS or the Windows Boot Manager accessible by pressing F9
    – JRichter
    Jul 10, 2015 at 1:49
  • Thanks I figured you had, just trying to rule out the easy stuff. Jul 10, 2015 at 1:50
  • Another thing to rule out. It looks like your PC has EFI. Did you install a 64 bit Ubuntu? Jul 10, 2015 at 1:52

2 Answers 2

4

According your Boot Info Summary

=> Windows 7/8/2012 is installed in the MBR of /dev/sda.

you have Windows bootloader installed into MBR, and grub installed into partition /dev/sda6. So your computer boots directly to Windows bootloader which knows nothing about your grub, linux and so on.

You need to install grub directly to sda, not to partition (sda6).

To do so, boot in your Linux using any way (you can use Plop Boot Manager from CD or any), and do in console sudo grub-install /dev/sda (this installs it in the mbr), and then sudo update-grub (this updates the grub menu).

Judging by your grub.conf found on sda6, update-grub adds Windows boot entries to menu automatically.

Then you can boot into any installed OS and linux too (seems it will be default option).

3
  • 1
    You actually should not have Windows in the gpt drive's protective MBR. Windows only boots with UEFI from gpt partitioned drives. And you have Ubuntu installed in UEFI boot mode also. But Sony is only Windows friendly. askubuntu.com/questions/486752/…
    – oldfred
    Jul 10, 2015 at 3:27
  • Thanks guys I will try these corrections out this weekend and let you know how it goes. I appreciate the help
    – JRichter
    Jul 10, 2015 at 21:40
  • @oldfred I have posted an answer that solved my issues. I appreciate your help and I would love if you could read my answer and let me know if there is anything you would correct. I know you are very experienced with this stuff and I just want to make an educated and accurate answer for people that have a similar issue as I did. Thanks.
    – JRichter
    Jul 16, 2015 at 1:15
1

After numerous attempts to solve this issue I finally resolved it with a few tips from various sources. First of all, I appreciate everyone's help in attempting to solve this issue. None of the answers worked directly but they all helped me in finding a solution to the problem, so thank you.

Installing GRUB directly into the MBR of /dev/sda did not work because I believe Windows and Sony did a very good job disguising how Windows actually boots on my machine. In the end I had to copy the "grubx64.efi" file over the boot manager file for Windows. Here are the steps I took in order to do this safely and efficiently. I will go through every step I took in installing Ubuntu incase anyone with a similar issue needs a thorough answer.

Steps To Install Ubuntu 15.04 on a Sony Vaio S with Windows 7

NOTE: This Process should only be used if you feel that you have exhausted all other possible options. This process will work but it requires renaming Windows boot files, which can be dangerous if not done properly. I highly recommend backing up important information before continuing.

  1. Prepare Hard Drive for Ubuntu Install

    • Boot into Windows
    • If desired you can defrag your hard drive but this is not necessary
    • Shrink your Windows Partition by the desired amount. I recommend deciding how much space you would like for all your files and the install and such, and then adding the size of your RAM to this amount.
      • For a visual tutorial on how to shrink your partition click here
      • Example: I wanted 50GB reserved for my Ubuntu system, and I have 16GB of RAM. Therefore I shrunk my partition by 66GB. Windows calculates the shrink in MB however, so you need to multiply your desired size by 1024. In my case, 66 x 1024 = 67584MB
    • NOTE: If your current install does not already have a ESP (EFI System Partition) then I recommend following another tutorial for your install. This tutorial specifically targets installs on computers with an ESP causing boot problems because of Windows security measures. Learn more about UEFI and ESP here
  2. Boot Ubuntu from Live CD or USB

    • When the GRUB menu shows up click "Try Ubuntu without Installing" If you are unfamiliar with Ubuntu I recommend playing around for a little while to make sure this is something you want to install. Mind the fact that everything will load very slowly considering you are operating out of a CD or USB stick.
  3. When Ubuntu is finally up and running click the logo on the Desktop that says "Install Ubuntu XX.XX" with whatever version you are installing. In my case it was 15.04.

  4. Click through the menu following the instructions (I recommend clicking on the install "3rd Party Drivers" and "Install Updates" check boxes if you have a fast internet connection and especially if you are installing on an SSD.

    If you feel like having a quicker install then don't check these boxes as you can always do these steps later.

  5. IMPORTANT: When you reach the menu that says "Allocate Drive Space" you want to click the option that says "Something Else" because this is where we set up your partitions that you prepared for in Step 1.

  6. Create Partitions:

    • Create partition for the swap. Select the free space partition then click the plus button to the lower left. Make the size equivalent to your RAM size, in my case it was 16GB (16384MB). Select "Primary" for type of partition, "Beginning of space" for location and "swap" for use as section. Note: The mount point option should disappear on selection of "swap". Click "OK"
    • Create partition for all your files and root. This is the main partition where all your files and programs will be located. Select the free space, click the plus button to the lower left. Make the size equivalent to the remaining free space you have (the editor should do this automatically). Select "Primary" for the partition type, "Beginning of this space" for the location, "Ext4 journaling file system" for use as and lastly select "/" (root) for the mount point. Click "OK"

      NOTE: There should be no more "free space" remaining. If you have some left over make sure that all of your partition sizes add up to the total number of MB you shrunk windows by in Step 1.

    • IMPORTANT: When selecting the option for "Device for boot loader installation" you want to select the same location as your "/boot" directory. Since this is an install on an ESP system, your boot directory will be in the same location as the Windows Boot Manager.

      In my case this was "/dev/sda3" but there should be a description saying "Windows Boot Manager" or something of that sort so you know which device your ESP is on.

      If there is no description in the installer, then open GParted and look in the Label section for something describing a Windows Boot Manager, this is location you are looking for. Select that device in the "Device for boot loader installation"

    • Now Click the "Install Now" button in the bottom right. THIS IS THE POINT OF NO RETURN. ONLY CONTINUE IF YOU ARE SURE YOU HAVE SET EVERYTHING CORRECTLY

    When the installation is finished DO NOT CLICK RESTART. Please click the "Continue Trying Ubuntu" link and continue to Step 7.

  7. Close all open programs and windows.

    NOTE: In this section replace "/dev/sda3" with the device you chose for boot loader installation at the end of Step 6.

    Open the Terminal and do the following while making sure to read carefully and TAKE YOUR TIME.

    We need to determine where your Windows Boot Manager file is located. It is most likely going to be in the path of "/EFI/Microsoft/Boot/bootmgfw.efi", as was mine, but we need to make sure.

    The only way I know how to do this is by updating grub and letting it tell us where it found the boot manager. Do this by typing the following, remembering to replace "/dev/sda3" with the device you installed your boot loader into:

    sudo mount /dev/sda3 /mnt
    cd /mnt
    sudo update-grub
    

    The cd /mnt command is necessary in order to get into the directory where grub was installed and it will also be useful later when navigating to different directories. The update-grub command should spit something out like the following. This is what mine spit out:

    jrichter@RICKY:~$ sudo update-grub
    Generating grub configuration file ...
    Found linux image: /boot/vmlinuz-3.19.0-22-generic
    Found initrd image: /boot/initrd.img-3.19.0-22-generic
    Found linux image: /boot/vmlinuz-3.19.0-15-generic
    Found initrd image: /boot/initrd.img-3.19.0-15-generic
    Found Windows Boot Manager on /dev/sda3@/EFI/Microsoft/Boot/bootmgfw.efi
    done
    

    Looking at the last line, the line before "done", we should see where the boot manager was found. Mine says the Windows Boot Manager was found on /dev/sda3 at the location /EFI/Microsoft/Boot/bootmgfw.efi This is the exact location of the boot file that is called when your system boots normally, and this is what we need to replace.

    NOTE: If you get an error updating GRUB or it does not find a location for the Windows Boot Manager then you likely mounted the wrong device or you installed the boot loader onto the wrong device during the installation period.

    If everything ran without error and you now understand the file and location that Windows boots from then we are ready to move on. For the remaining steps remember to replace the location in which my boot file is located with the location of yours, although I would bet they are the same.

    Continue by typing the following commands:

    Go to the directory in which your boot file is located:

    cd EFI/Microsoft/Boot
    

    Copy the normal Windows boot file to a backup and a new file we are calling "bootwin.efi" that we will set Windows 7 to boot to inside GRUB:

    sudo cp bootmgfw.efi bootmgfw.efi.bkp
    sudo cp bootmgfw.efi bootwin.efi
    

    Copy the GRUB loader file over the normal Windows boot file. This is to fake your machine into thinking it is loading Windows, but instead it will load the GRUB menu. Type the following:

    cd /mnt/EFI
    sudo cp ubuntu/grubx64.efi Microsoft/Boot/bootmgfw.efi
    

    Change back to the main directory, unmount your boot loader device and reboot the computer. Note that the command to unmount is called umount NOT unmount:

    cd
    sudo umount /dev/sda3
    sudo reboot
    
  8. After the the computer reboots it SHOULD boot into the GRUB menu.

    NOTE: We are no longer using the Live CD or USB so make sure those are removed. If it does not boot to GRUB then you have likely made a mistake somewhere along the road, or the file we copied over ("bootmgfw.efi") is not actually the file called when Windows Boot Manager starts up.

    • If you encounter this error I recommend downloading rEFInd to a bootable CD. Insert the bootable CD and start your computer. rEFInd should be able to see all boot files and give you options to boot. I recommend going through these options until you find one that boots Windows normally. Note: The file being called on boot is under the option selection in rEFInd. Use this as the file in which to copy over with "grubx64.efi"
  9. Once you have loaded the GRUB menu please boot into Ubuntu.

    Note: If all steps were performed correctly, selecting the Windows Boot Manager option should bring you back to the GRUB menu. This is because we copied over the file to boot Windows Boot Manager with the file to boot GRUB.

  10. Now that we are back in Ubuntu, open the Terminal and type the following commands:

    Start an administrator terminal by typing:

    sudo -s
    

    This allows us to make root level commands without having to type sudo every time. Now type the following to find the file in which to add a Windows entry to:

    cd /etc/grub.d
    ls
    

    This should give you a list of files. Look for one that looks like "XX_custom" where XX is a number, probably a multiple of ten. In my case it was "40_custom". This is what the file should look like:

    #!/bin/sh
    exec tail -n +3 $0
    # 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.
    

    Type the following commands to add a menu entry for Windows (replacing "40_custom" with your appropriate file name):

    nano 40_custom
    

    Add a menu entry below all the comments (represented with a #).

    NOTE: Replace 'hd0,gpt3' with the appropriate hard drive and device that your boot loader is on (this is the same location as where you installed your boot loader on during installation where gpt3 represents sda3 for example). Also replace the line after "chainloader" with the same location you determined your Windows boot file to be in.

    Now type the following, making sure the filename at the end is the filename we created earlier by copying "bootmgfw.efi". I named mine "bootwin.efi":

    menuentry "Windows 7" {
        root='hd0,gpt3'
        chainloader /EFI/Microsoft/Boot/bootwin.efi
    }
    

    Now Press "Ctrl-X" then Press "Y" and then Press "Enter" to save the changes. Make sure you are in a sudo -s terminal otherwise you will not be allowed to make changes.

    And lastly, we need to update GRUB with our new entry and reboot the system to make sure everything works. Do this by typing:

    update-grub
    reboot
    
  11. Upon your system booting, GRUB should load by default and you should see a new entry with the name you gave it in the "XX_custom" file. In my case it says "Windows 7". Choose the Windows option to make sure it loads properly, as it should boot Windows in the same way it did before the install.

  12. Reboot and confirm that the Ubuntu option still works.

  13. Congrats! You are all done and if everything went correctly you have officially installed Ubuntu on a machine with ESP alongside Windows. You can now dual boot the two best operating systems out there :)

5
  • After Windows shrink, reboot Windows so it can do its chkdsk. Otherwise Ubuntu installer may not see it. With UEFI you still specify installing grub to a drive like sda, not sda3 a partition. But with UEFI it really does not matter as system is smart enough to know to install grub's boot files into ESP - efi system partition. Renaming Windows efi boot file can be done but is not recommended anymore. Windows updates will regularly overwrite it, and you have to copy grub again. Most system work from hard drive entry or /EFI/Boot/bootx64.efi, so better to make that file really be grub.
    – oldfred
    Jul 16, 2015 at 3:42
  • @oldfred Well I did it that way first and it didn't work. Not sure why but after many attempts this was the only thing that actually worked.
    – JRichter
    Jul 16, 2015 at 3:43
  • Just be ready when Windows does an update to have to copy grub again.
    – oldfred
    Jul 16, 2015 at 3:50
  • I wonder how often those updates come because windows ran about 25 updates yesterday after the install and nothing got messed up.
    – JRichter
    Jul 16, 2015 at 3:51
  • It probably is like a grub or kernel update with Ubuntu were grub menu is then updated. But grub in MBR with BIOS or efi with UEFI is only updated with a major grub version update.
    – oldfred
    Jul 16, 2015 at 3:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .