Restore grub after windows install

I installed Windows 7, which ate Ubuntu’s boot file. When starting up the computer, it now goes straight to Windows, without giving me the option of booting Ubuntu.

How can I get Ubuntu back?

Mattlinux1's user avatar

Mattlinux1

6902 gold badges7 silver badges23 bronze badges

asked Dec 17, 2011 at 7:02

Salahuddin's user avatar

5

When you install Windows, Windows assumes it is the only operating system (OS) on the machine, or at least it does not account for Linux. So it replaces GRUB with its own boot loader. What you have to do is replace the Windows boot loader with GRUB. I’ve seen various instructions for replacing GRUB by mucking around with GRUB commands or some such, but to me the easiest way is to simply chroot into your install and run update-grub. chroot is great because it allows you to work on your actual install, instead of trying to redirect things here and there. It is really clean.

Here’s how:

  1. Boot from the live CD or live USB, in «Try Ubuntu» mode.

  2. Determine the partition number of your main partition. sudo fdisk -l, sudo blkid or GParted (which should already be installed, by default, on the live session) can help you here. I’m going to assume in this answer that it’s /dev/sda2, but make sure you use the correct partition number for your system!

    If your main partition is in an LVM, the device will instead be located in /dev/mapper/, most likely, /dev/mapper/{volume}--{os}-root where {volume} is the LVM volume name and {os} is the operating system. Execute ls /dev/mapper for the exact name.

  3. Mount your partition:

     sudo mount /dev/sda2 /mnt  #Replace sda2 with the partition from step 2
    

    If you have a separate /boot, /var or /usr partitions, repeat steps 2 and 3 to mount these partitions to /mnt/boot, /mnt/var and /mnt/usr respectively. For example,

     sudo mount /dev/sdXW /mnt/boot
     sudo mount /dev/sdXY /mnt/var
     sudo mount /dev/sdXZ /mnt/usr
    

    replacing sdXW, sdXY, and sdXZ with the respective partition numbers.

  4. Bind mount some other necessary stuff:

     for i in /sys /proc /run /dev; do sudo mount --rbind "$i" "/mnt$i"; done
    
  5. If Ubuntu is installed in EFI mode (see this answer if you’re unsure), use sudo fdisk -l | grep -i efi or GParted to find your EFI partition. It will have a label of EFI. Mount this partition, replacing sdXY with the actual partition number for your system:

     sudo mount /dev/sdXY /mnt/boot/efi
    
  6. chroot into your Ubuntu install:

     sudo chroot /mnt
    
  7. At this point, you’re in your install, not the live session, and running as root. Update grub:

     update-grub
    

    If you get errors or if going up to step 7 didn’t fix your problem, go to step 8. (Otherwise, it is optional.)

  8. Depending on your situation, you might have to reinstall grub:

     grub-install /dev/sda
     update-grub # In order to find and add windows to grub menu.
    
  9. If Ubuntu is installed in EFI mode, and EFI partition UUID has changed, you may need to update it in /etc/fstab. Compare it:

     blkid | grep -i efi
     grep -i efi /etc/fstab
    

    If current EFI partition UUID (from blkid) differs from the one in /etc/fstab, update /etc/fstab with current UUID.

  10. If everything worked without errors, then you’re all set:

    exit
    sudo reboot
    
  11. At this point, you should be able to boot normally.

If you cannot boot normally, and didn’t do step 8 because there were no error messages, try again with step 8.

  • Sometimes giving GRUB2 the correct configuration for your partitions is not enough, and you must actually install it (or reinstall it) to the Master Boot Record, which step 8 does. Experience helping users in chat has shown that step 8 is sometimes necessary even when no error messages are shown.

answered Dec 17, 2011 at 12:23

Scott Severance's user avatar

Scott SeveranceScott Severance

13.8k9 gold badges52 silver badges76 bronze badges

29

The Windows installer doesn’t care about other OS in the system. So it writes own code over the master boot record. Fortunately the solution is easy too.

You need to repair the MBR. Do the following

Boot using a live usb/cd of ubuntu.
Use boot-repair to fix the problem.

After booting with live usb/cd, run following command in terminal:

sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
sudo apt-get install -y boot-repair && boot-repair

Use Recomended Repair.

enter image description here

More info — https://help.ubuntu.com/community/Boot-Repair

Mikel's user avatar

Mikel

6,4783 gold badges30 silver badges29 bronze badges

answered Sep 1, 2012 at 6:59

Web-E's user avatar

Web-EWeb-E

21.4k12 gold badges52 silver badges93 bronze badges

13

Boot from a live Ubuntu USB pendrive or CD
and
Install Boot-Repair on ubuntu by following steps

Open the terminal and run the following commands

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install boot-repair

After completing the installation you can launch it from System->Administration->Boot-Repair menu if you use Gnome, or search «boot-repair» in the dash if you use Unity. Then follow the following screenshots:

Method 1

  • Click on the advanced options

Initial screen

  • Tick the options shown below

advanced option

  • Change the tab to Grub Location Tab and Tick The options Shown in the figure

enter image description here

Press Apply and Reboot the system

Method 2

  • Select the recommended Boot repair options as shown in the first screenshot

Documentation :

answered Jul 30, 2013 at 19:25

Stormvirux's user avatar

StormviruxStormvirux

4,45629 silver badges35 bronze badges

2

Just install easyBCD in Windows 7 and do

Add New Entry > Linux/BSD > (select ) Grub2 > (push) Add Entry

Then you can choose Ubuntu on the Windows 7 bootloader to go to Grub2 (previous bootloader).

Zanna's user avatar

Zanna

69.5k56 gold badges217 silver badges328 bronze badges

answered Mar 11, 2012 at 22:09

Hamed's user avatar

HamedHamed

5141 gold badge9 silver badges19 bronze badges

4

On EFI-based systems (such as most systems that shipped with Windows 8 or later), Windows will sometimes update its boot loader or reset it to be the default boot loader. This is particularly common when re-installing the OS or performing a major system update (upgrading to the latest Windows release, for instance). Note that Windows is unlikely to actually erase any GRUB files on an EFI-based computer. Everything needed to boot Ubuntu is still in place; it’s just being bypassed. In these cases, a complete re-installation of GRUB is overkill, and in fact that carries a (small) chance that it will create new problems.

Thus, instead of re-installing GRUB in these cases, I recommend resetting GRUB (or whatever boot loader or boot manager you prefer) to be the default. There are several ways to do this, including:

  • EasyUEFI — The easiest way to adjust the boot order, if the system is booting straight to Windows, is to use EasyUEFI, which is a free (for the basic version) third-party GUI tool for managing the EFI boot order. It’s pretty self-explanatory — locate the ubuntu entry in the list of boot options and move it to the top of the list. The next time you reboot, GRUB should come up. (If you use something other than GRUB, you’ll need to locate its entry.)
  • bcdedit — The Windows bcdedit tool can be used to set GRUB to the default boot order. The command bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi, typed in an Administrator Command Prompt window, will do this; however, if your computer boots with Secure Boot active, bcdedit /set {bootmgr} path \EFI\ubuntu\shimx64.efi will be required instead. In fact, the latter command will usually work even if Secure Boot is not in use, so I’d use that command first. Note that there’s a more advanced Windows shell tool that requires a slightly different syntax than I’ve presented, but I don’t recall the details.
  • One-time boot to Ubuntu — Most EFIs provide a built-in boot manager, accessed by hitting a function key, Esc, or Enter early in the system start process. Chances are the ubuntu entry to boot Ubuntu will show up in this boot manager menu, enabling you to boot to Ubuntu. Alternatively, you could boot to an Ubuntu emergency medium, like the installer booted in «try before installing» mode. Either way, you can then use efibootmgr to adjust the boot order:
    1. Type sudo efibootmgr to see the boot entries.
    2. Note the current BootOrder line.
    3. Locate the entry for ubuntu and note its Boot#### number.
    4. Type sudo efibootmgr -o xxxx[,yyyy,zzzz,....] to change the boot order, making xxxx the number for Ubuntu. What comes after that is most likely not very important, although I’ve noted that Windows seems to be likely to add itself back to the start of the boot order if it’s not in the list. Thus, you should probably ensure that Windows is in the list, and it may be safest to re-order the list so that all the original entries are there, just with the ubuntu entry moved to the top of the list.
  • Firmware setup utility — Some EFIs’ setup utilities enable you to adjust the boot order. Details vary greatly from one EFI to another, so I won’t go into specifics, but you could look for such an option in your setup utility.

There are other variants on these procedures, such as using bcfg in an EFI shell, using bless in macOS, using my rEFInd to do a one-time boot, etc. I’d start with EasyUEFI, though; it’s likely to be the simplest solution. Sometimes Windows insists on making itself the default every time it starts up, though, and reports indicate that bcdedit may do a better job of dealing with that problem.

Note that none of the preceding applies to BIOS-mode installations; however, as most computers that shipped with Windows 8 or later boot in EFI mode, BIOS-mode installations are becoming increasingly rare, so in many cases it’s better to deal with the issue in the EFI way rather than by blindly re-installing GRUB.

answered Jul 13, 2017 at 15:03

Rod Smith's user avatar

Rod SmithRod Smith

43.7k7 gold badges63 silver badges102 bronze badges

2

There is now a simpler solution:

  1. Reboot, and enter your computer’s BIOS options (F2, or sometimes F11).
  2. Go to the Boot menu, and select Boot Device Priority
  3. Check if Windows Boot Manager is above the main boot drive (usually SATA HDD … or IDE HDD …). If it is, move the boot disk priority above that of Windows Boot Manager.
  4. Save your BIOS options, and exit (usually F10).

This has been tested on a Samsung Series 7 Chronos laptop dual booting Windows 8 and Ubuntu 13.10, secure boot disabled, UEFI and legacy boot enabled.

answered Dec 15, 2013 at 13:04

scruss's user avatar

scrussscruss

1,2343 gold badges14 silver badges28 bronze badges

4

Boot-Repair worked for me. It’s very very easy to use graphical application, you do not need to use the command line, you only have to click a button :)

All the available repair options are described in the Ubuntu documentation and there is a separate page explaining how to start Boot-Repair (by creating a bootable disk or installing it in an existing Ubuntu live disk) and how to use it.

Just boot a Ubuntu live CD, install Boot-Repair and run it.

metakermit's user avatar

metakermit

2,6103 gold badges28 silver badges34 bronze badges

answered Dec 18, 2011 at 1:41

lorenzo-s's user avatar

lorenzo-slorenzo-s

4853 gold badges8 silver badges17 bronze badges

1

When GRUB is broken, the user generally does not have access to systems, so repair must be performed from a live-session (live-CD or live-USB).

There are many possible causes to a GRUB break: Windows writing on the MBR, DRM preventing GRUB from installing correctly, installer bug, hardware change…
Updating GRUB as proposed initially by Scott is generally not sufficient, reinstalling GRUB as proposed by Marco is more efficient, but still there are various situations requiring other tweaks (adding options to kernel, unhiding GRUB menu, changing GRUB options, choosing the right host architecture…).
Other difficulties for repairing GRUB is the use of chroot, and the choice of the right partitions /disks.

All of this has been made easy in a little graphical tool: Boot-Repair. It
shall be integrated in Ubuntu 12.04 CD for easier use, but for people needing it now, there are already some distros integrating it: Ubuntu-Secured-Remix (Ubuntu CD integrating Boot-Repair), Boot-Repair-Disk (CD running Boot-Repair at start-up), …

Hope this helps.

answered Dec 20, 2011 at 8:58

LovinBuntu's user avatar

LovinBuntuLovinBuntu

3,5952 gold badges19 silver badges21 bronze badges

Answers given by Scott and Web-E are good enough and have helped a lot many times. But many a times, the boot-repair tool is not able to repair grub due to problems related to i386 and amd64 platform or one where grub can’t find efi directory.
What has solved my problem like more than 10 times is to manually purge the old grub installations and install a new one.

So first perform the first 6 steps from Scott’s answer where you can skip the 5th step if it gives an error:

  1. Boot from the live CD or live USB, in «Try Ubuntu» mode.
  2. Determine the partition number of your main partition. sudo fdisk -l, sudo blkid or GParted (which should already be installed, by default, on the live session) can help you here. I’m going to assume
    in this answer that it’s /dev/sda2, but make sure you use the
    correct partition number for your system!

    If your main partition is in an LVM, the device will instead be located in /dev/mapper/, most likely,
    /dev/mapper/{volume}--{os}-root where {volume} is the LVM volume
    name and {os} is the operating system. Execute ls /dev/mapper for
    the exact name.

  3. Mount your partition:

    sudo mount /dev/sda2 /mnt  #Replace sda2 with the partition from step 2
    

    If you have a separate /boot, /var or /usr partitions, repeat steps 2 and 3 to mount these partitions to /mnt/boot,
    /mnt/var and /mnt/usr respectively. For example,

    sudo mount /dev/sdXW /mnt/boot
    sudo mount /dev/sdXY /mnt/var
    sudo mount /dev/sdXZ /mnt/usr
    

    replacing sdXW, sdXY, and sdXZ with the respective partition numbers.

  4. Bind mount some other necessary stuff:

    for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done
    
  5. If Ubuntu is installed in EFI mode ([see this answer if you’re unsure][efi]), use sudo fdisk -l | grep -i efi or GParted to find
    your EFI partition. It will have a label of EFI. Mount this
    partition, replacing sdXY with the actual partition number for your
    system:

    sudo mount /dev/sdXY /mnt/boot/efi
    
  6. chroot into your Ubuntu install:

    sudo chroot /mnt
    

Then do these steps:

  1. Configure all the pending packages.
    sudo dpkg --configure -a
  2. Fix the broken packages.
    sudo apt install -fy
  3. Remove the current grub.
    sudo apt purge -y grub*-common grub-common:i386 shim-signed
    This may give you a warning that your device will have no bootloader
    and may be unable to boot the next time. Go ahead and accept it.
  4. sudo apt install -y grub-pc
    After running this command, it will ask you to point the current sdXY to install the bootloader. Find where your current OS is installed using sudo fdisk -l command. It will be labelled as Linux. Navigate that window using Tab key and select an option using Space key.
  5. If everything goes right, grub will be installed correctly. You can also do sudo grub-update for a double check.

If the problem still persists, you can read Arch’s wiki to actually understand about grub to tackle many other varieties of problems. (Yes, also helps for Ubuntu!).

answered Sep 6, 2018 at 14:28

subtleseeker's user avatar

Scott Severance’s answer is valid and detailed but there is a resolution that requires no external boot device and so no need to identify and manually mount all of your Ubuntu partitions leading up to the chroot.

In Windows 10, you can use Advanced Recovery to select a device (partition?) to boot from.

Go to Settings and choose Update & Security:

enter image description here

Go to Recovery:

enter image description here

From Advanced Startup choose Restart Now

enter image description here

Then choose Use a Device and all the boot options should be presented to you. Choose the ‘ubuntu’ partition and your PC should then boot from that partition.

Once booted into my usual Ubuntu environment, I have tried just running grub-update but that made no change.

I then found my /boot/efi partition which was /dev/nvme0n1p1 and ran sudo grub-install /dev/nvme0n1p1 and then sudo update-grub.

This has restored my master boot record multiple times now as there seems to be a new Windows 10 policy of overwriting boot info on minor updates.

answered Jun 2, 2019 at 0:47

timbo's user avatar

timbotimbo

3231 gold badge4 silver badges14 bronze badges

2

It turns out grub can be fixed from Windows too. Running the following (as administrator) from CMD brought the grub menu back for me.

bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi

answered Oct 8, 2020 at 15:14

mindlessgreen's user avatar

1

Windows does not see Linux formatted partitions. You need to use gparted from a liveCD and create a primary partition formatted NTFS with the boot flag.

Some have had issues if the new primary partition is after the extended partition as Windows does not always reset partition table correctly. Best to have good backups and a separate backup of partition table.

Backup partition table to text file & save to external device.

sudo sfdisk -d /dev/sda > PTsda.txt

This is only for MBR (msdos) systems. If your Ubuntu install is in GPT partition drive you can only install Windows in UEFI mode or convert drive back to MBR (msdos).

wjandrea's user avatar

wjandrea

14.1k4 gold badges48 silver badges98 bronze badges

answered Jul 30, 2013 at 20:01

oldfred's user avatar

oldfredoldfred

11.8k3 gold badges23 silver badges33 bronze badges

2

Only fsck command fixed the grub-rescue screen for me.

Use Boot-Repair to boot from Live-CD, then open Terminal

Get the correct device:

sudo fdisk -l

Need to find the boot device, the boot device has * under Boot category like here:

Device     Boot   Start       End   Sectors  Size Id Type
/dev/sda1          2048   2000895   1998848  976M 82 Linux swap / Solaris
/dev/sda2  *    2000896 943716351 941715456  449G 83 Linux

Now repair the disk by using:

sudo fsck /dev/sda2 -y

Note: /dev/sda2 is the boot device in this example.

Reboot when completed. Done.

answered Jul 25, 2018 at 7:51

Benny's user avatar

BennyBenny

4,8002 gold badges19 silver badges33 bronze badges

I had a different issue, caused (probably) by boot-repair wiping my /etc/grub.d/ templates, outlined in my question here: Ubuntu 18.04 not booting after Windows 10 install

As pointed out by @karels comment, the grub config is generated using the files in /etc/grub.d. My directory only contained /etc/grub.d/25_custom, which contained strange menu entries pointing to non-existent .efi images. It looked like my /etc/grub.d templates were maybe hosed by boot-repair.

I fixed this by:

  1. Boot with Live CD (probably important to use same Ubuntu version)
  2. sudo mount /dev/sdxx /mnt
  3. sudo cp /etc/grub.d/* /mnt/etc/grub.d/
  4. sudo update-grub
  5. Reboot & relax after 48 hours of pain

answered Aug 29, 2019 at 9:58

Adam Moore's user avatar

You must log in to answer this question.

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

.

I installed Windows 7, which ate Ubuntu’s boot file. When starting up the computer, it now goes straight to Windows, without giving me the option of booting Ubuntu.

How can I get Ubuntu back?

Mattlinux1's user avatar

Mattlinux1

6902 gold badges7 silver badges23 bronze badges

asked Dec 17, 2011 at 7:02

Salahuddin's user avatar

5

When you install Windows, Windows assumes it is the only operating system (OS) on the machine, or at least it does not account for Linux. So it replaces GRUB with its own boot loader. What you have to do is replace the Windows boot loader with GRUB. I’ve seen various instructions for replacing GRUB by mucking around with GRUB commands or some such, but to me the easiest way is to simply chroot into your install and run update-grub. chroot is great because it allows you to work on your actual install, instead of trying to redirect things here and there. It is really clean.

Here’s how:

  1. Boot from the live CD or live USB, in «Try Ubuntu» mode.

  2. Determine the partition number of your main partition. sudo fdisk -l, sudo blkid or GParted (which should already be installed, by default, on the live session) can help you here. I’m going to assume in this answer that it’s /dev/sda2, but make sure you use the correct partition number for your system!

    If your main partition is in an LVM, the device will instead be located in /dev/mapper/, most likely, /dev/mapper/{volume}--{os}-root where {volume} is the LVM volume name and {os} is the operating system. Execute ls /dev/mapper for the exact name.

  3. Mount your partition:

     sudo mount /dev/sda2 /mnt  #Replace sda2 with the partition from step 2
    

    If you have a separate /boot, /var or /usr partitions, repeat steps 2 and 3 to mount these partitions to /mnt/boot, /mnt/var and /mnt/usr respectively. For example,

     sudo mount /dev/sdXW /mnt/boot
     sudo mount /dev/sdXY /mnt/var
     sudo mount /dev/sdXZ /mnt/usr
    

    replacing sdXW, sdXY, and sdXZ with the respective partition numbers.

  4. Bind mount some other necessary stuff:

     for i in /sys /proc /run /dev; do sudo mount --rbind "$i" "/mnt$i"; done
    
  5. If Ubuntu is installed in EFI mode (see this answer if you’re unsure), use sudo fdisk -l | grep -i efi or GParted to find your EFI partition. It will have a label of EFI. Mount this partition, replacing sdXY with the actual partition number for your system:

     sudo mount /dev/sdXY /mnt/boot/efi
    
  6. chroot into your Ubuntu install:

     sudo chroot /mnt
    
  7. At this point, you’re in your install, not the live session, and running as root. Update grub:

     update-grub
    

    If you get errors or if going up to step 7 didn’t fix your problem, go to step 8. (Otherwise, it is optional.)

  8. Depending on your situation, you might have to reinstall grub:

     grub-install /dev/sda
     update-grub # In order to find and add windows to grub menu.
    
  9. If Ubuntu is installed in EFI mode, and EFI partition UUID has changed, you may need to update it in /etc/fstab. Compare it:

     blkid | grep -i efi
     grep -i efi /etc/fstab
    

    If current EFI partition UUID (from blkid) differs from the one in /etc/fstab, update /etc/fstab with current UUID.

  10. If everything worked without errors, then you’re all set:

    exit
    sudo reboot
    
  11. At this point, you should be able to boot normally.

If you cannot boot normally, and didn’t do step 8 because there were no error messages, try again with step 8.

  • Sometimes giving GRUB2 the correct configuration for your partitions is not enough, and you must actually install it (or reinstall it) to the Master Boot Record, which step 8 does. Experience helping users in chat has shown that step 8 is sometimes necessary even when no error messages are shown.

answered Dec 17, 2011 at 12:23

Scott Severance's user avatar

Scott SeveranceScott Severance

13.8k9 gold badges52 silver badges76 bronze badges

29

The Windows installer doesn’t care about other OS in the system. So it writes own code over the master boot record. Fortunately the solution is easy too.

You need to repair the MBR. Do the following

Boot using a live usb/cd of ubuntu.
Use boot-repair to fix the problem.

After booting with live usb/cd, run following command in terminal:

sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
sudo apt-get install -y boot-repair && boot-repair

Use Recomended Repair.

enter image description here

More info — https://help.ubuntu.com/community/Boot-Repair

Mikel's user avatar

Mikel

6,4783 gold badges30 silver badges29 bronze badges

answered Sep 1, 2012 at 6:59

Web-E's user avatar

Web-EWeb-E

21.4k12 gold badges52 silver badges93 bronze badges

13

Boot from a live Ubuntu USB pendrive or CD
and
Install Boot-Repair on ubuntu by following steps

Open the terminal and run the following commands

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install boot-repair

After completing the installation you can launch it from System->Administration->Boot-Repair menu if you use Gnome, or search «boot-repair» in the dash if you use Unity. Then follow the following screenshots:

Method 1

  • Click on the advanced options

Initial screen

  • Tick the options shown below

advanced option

  • Change the tab to Grub Location Tab and Tick The options Shown in the figure

enter image description here

Press Apply and Reboot the system

Method 2

  • Select the recommended Boot repair options as shown in the first screenshot

Documentation :

answered Jul 30, 2013 at 19:25

Stormvirux's user avatar

StormviruxStormvirux

4,45629 silver badges35 bronze badges

2

Just install easyBCD in Windows 7 and do

Add New Entry > Linux/BSD > (select ) Grub2 > (push) Add Entry

Then you can choose Ubuntu on the Windows 7 bootloader to go to Grub2 (previous bootloader).

Zanna's user avatar

Zanna

69.5k56 gold badges217 silver badges328 bronze badges

answered Mar 11, 2012 at 22:09

Hamed's user avatar

HamedHamed

5141 gold badge9 silver badges19 bronze badges

4

On EFI-based systems (such as most systems that shipped with Windows 8 or later), Windows will sometimes update its boot loader or reset it to be the default boot loader. This is particularly common when re-installing the OS or performing a major system update (upgrading to the latest Windows release, for instance). Note that Windows is unlikely to actually erase any GRUB files on an EFI-based computer. Everything needed to boot Ubuntu is still in place; it’s just being bypassed. In these cases, a complete re-installation of GRUB is overkill, and in fact that carries a (small) chance that it will create new problems.

Thus, instead of re-installing GRUB in these cases, I recommend resetting GRUB (or whatever boot loader or boot manager you prefer) to be the default. There are several ways to do this, including:

  • EasyUEFI — The easiest way to adjust the boot order, if the system is booting straight to Windows, is to use EasyUEFI, which is a free (for the basic version) third-party GUI tool for managing the EFI boot order. It’s pretty self-explanatory — locate the ubuntu entry in the list of boot options and move it to the top of the list. The next time you reboot, GRUB should come up. (If you use something other than GRUB, you’ll need to locate its entry.)
  • bcdedit — The Windows bcdedit tool can be used to set GRUB to the default boot order. The command bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi, typed in an Administrator Command Prompt window, will do this; however, if your computer boots with Secure Boot active, bcdedit /set {bootmgr} path \EFI\ubuntu\shimx64.efi will be required instead. In fact, the latter command will usually work even if Secure Boot is not in use, so I’d use that command first. Note that there’s a more advanced Windows shell tool that requires a slightly different syntax than I’ve presented, but I don’t recall the details.
  • One-time boot to Ubuntu — Most EFIs provide a built-in boot manager, accessed by hitting a function key, Esc, or Enter early in the system start process. Chances are the ubuntu entry to boot Ubuntu will show up in this boot manager menu, enabling you to boot to Ubuntu. Alternatively, you could boot to an Ubuntu emergency medium, like the installer booted in «try before installing» mode. Either way, you can then use efibootmgr to adjust the boot order:
    1. Type sudo efibootmgr to see the boot entries.
    2. Note the current BootOrder line.
    3. Locate the entry for ubuntu and note its Boot#### number.
    4. Type sudo efibootmgr -o xxxx[,yyyy,zzzz,....] to change the boot order, making xxxx the number for Ubuntu. What comes after that is most likely not very important, although I’ve noted that Windows seems to be likely to add itself back to the start of the boot order if it’s not in the list. Thus, you should probably ensure that Windows is in the list, and it may be safest to re-order the list so that all the original entries are there, just with the ubuntu entry moved to the top of the list.
  • Firmware setup utility — Some EFIs’ setup utilities enable you to adjust the boot order. Details vary greatly from one EFI to another, so I won’t go into specifics, but you could look for such an option in your setup utility.

There are other variants on these procedures, such as using bcfg in an EFI shell, using bless in macOS, using my rEFInd to do a one-time boot, etc. I’d start with EasyUEFI, though; it’s likely to be the simplest solution. Sometimes Windows insists on making itself the default every time it starts up, though, and reports indicate that bcdedit may do a better job of dealing with that problem.

Note that none of the preceding applies to BIOS-mode installations; however, as most computers that shipped with Windows 8 or later boot in EFI mode, BIOS-mode installations are becoming increasingly rare, so in many cases it’s better to deal with the issue in the EFI way rather than by blindly re-installing GRUB.

answered Jul 13, 2017 at 15:03

Rod Smith's user avatar

Rod SmithRod Smith

43.7k7 gold badges63 silver badges102 bronze badges

2

There is now a simpler solution:

  1. Reboot, and enter your computer’s BIOS options (F2, or sometimes F11).
  2. Go to the Boot menu, and select Boot Device Priority
  3. Check if Windows Boot Manager is above the main boot drive (usually SATA HDD … or IDE HDD …). If it is, move the boot disk priority above that of Windows Boot Manager.
  4. Save your BIOS options, and exit (usually F10).

This has been tested on a Samsung Series 7 Chronos laptop dual booting Windows 8 and Ubuntu 13.10, secure boot disabled, UEFI and legacy boot enabled.

answered Dec 15, 2013 at 13:04

scruss's user avatar

scrussscruss

1,2343 gold badges14 silver badges28 bronze badges

4

Boot-Repair worked for me. It’s very very easy to use graphical application, you do not need to use the command line, you only have to click a button :)

All the available repair options are described in the Ubuntu documentation and there is a separate page explaining how to start Boot-Repair (by creating a bootable disk or installing it in an existing Ubuntu live disk) and how to use it.

Just boot a Ubuntu live CD, install Boot-Repair and run it.

metakermit's user avatar

metakermit

2,6103 gold badges28 silver badges34 bronze badges

answered Dec 18, 2011 at 1:41

lorenzo-s's user avatar

lorenzo-slorenzo-s

4853 gold badges8 silver badges17 bronze badges

1

When GRUB is broken, the user generally does not have access to systems, so repair must be performed from a live-session (live-CD or live-USB).

There are many possible causes to a GRUB break: Windows writing on the MBR, DRM preventing GRUB from installing correctly, installer bug, hardware change…
Updating GRUB as proposed initially by Scott is generally not sufficient, reinstalling GRUB as proposed by Marco is more efficient, but still there are various situations requiring other tweaks (adding options to kernel, unhiding GRUB menu, changing GRUB options, choosing the right host architecture…).
Other difficulties for repairing GRUB is the use of chroot, and the choice of the right partitions /disks.

All of this has been made easy in a little graphical tool: Boot-Repair. It
shall be integrated in Ubuntu 12.04 CD for easier use, but for people needing it now, there are already some distros integrating it: Ubuntu-Secured-Remix (Ubuntu CD integrating Boot-Repair), Boot-Repair-Disk (CD running Boot-Repair at start-up), …

Hope this helps.

answered Dec 20, 2011 at 8:58

LovinBuntu's user avatar

LovinBuntuLovinBuntu

3,5952 gold badges19 silver badges21 bronze badges

Answers given by Scott and Web-E are good enough and have helped a lot many times. But many a times, the boot-repair tool is not able to repair grub due to problems related to i386 and amd64 platform or one where grub can’t find efi directory.
What has solved my problem like more than 10 times is to manually purge the old grub installations and install a new one.

So first perform the first 6 steps from Scott’s answer where you can skip the 5th step if it gives an error:

  1. Boot from the live CD or live USB, in «Try Ubuntu» mode.
  2. Determine the partition number of your main partition. sudo fdisk -l, sudo blkid or GParted (which should already be installed, by default, on the live session) can help you here. I’m going to assume
    in this answer that it’s /dev/sda2, but make sure you use the
    correct partition number for your system!

    If your main partition is in an LVM, the device will instead be located in /dev/mapper/, most likely,
    /dev/mapper/{volume}--{os}-root where {volume} is the LVM volume
    name and {os} is the operating system. Execute ls /dev/mapper for
    the exact name.

  3. Mount your partition:

    sudo mount /dev/sda2 /mnt  #Replace sda2 with the partition from step 2
    

    If you have a separate /boot, /var or /usr partitions, repeat steps 2 and 3 to mount these partitions to /mnt/boot,
    /mnt/var and /mnt/usr respectively. For example,

    sudo mount /dev/sdXW /mnt/boot
    sudo mount /dev/sdXY /mnt/var
    sudo mount /dev/sdXZ /mnt/usr
    

    replacing sdXW, sdXY, and sdXZ with the respective partition numbers.

  4. Bind mount some other necessary stuff:

    for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done
    
  5. If Ubuntu is installed in EFI mode ([see this answer if you’re unsure][efi]), use sudo fdisk -l | grep -i efi or GParted to find
    your EFI partition. It will have a label of EFI. Mount this
    partition, replacing sdXY with the actual partition number for your
    system:

    sudo mount /dev/sdXY /mnt/boot/efi
    
  6. chroot into your Ubuntu install:

    sudo chroot /mnt
    

Then do these steps:

  1. Configure all the pending packages.
    sudo dpkg --configure -a
  2. Fix the broken packages.
    sudo apt install -fy
  3. Remove the current grub.
    sudo apt purge -y grub*-common grub-common:i386 shim-signed
    This may give you a warning that your device will have no bootloader
    and may be unable to boot the next time. Go ahead and accept it.
  4. sudo apt install -y grub-pc
    After running this command, it will ask you to point the current sdXY to install the bootloader. Find where your current OS is installed using sudo fdisk -l command. It will be labelled as Linux. Navigate that window using Tab key and select an option using Space key.
  5. If everything goes right, grub will be installed correctly. You can also do sudo grub-update for a double check.

If the problem still persists, you can read Arch’s wiki to actually understand about grub to tackle many other varieties of problems. (Yes, also helps for Ubuntu!).

answered Sep 6, 2018 at 14:28

subtleseeker's user avatar

Scott Severance’s answer is valid and detailed but there is a resolution that requires no external boot device and so no need to identify and manually mount all of your Ubuntu partitions leading up to the chroot.

In Windows 10, you can use Advanced Recovery to select a device (partition?) to boot from.

Go to Settings and choose Update & Security:

enter image description here

Go to Recovery:

enter image description here

From Advanced Startup choose Restart Now

enter image description here

Then choose Use a Device and all the boot options should be presented to you. Choose the ‘ubuntu’ partition and your PC should then boot from that partition.

Once booted into my usual Ubuntu environment, I have tried just running grub-update but that made no change.

I then found my /boot/efi partition which was /dev/nvme0n1p1 and ran sudo grub-install /dev/nvme0n1p1 and then sudo update-grub.

This has restored my master boot record multiple times now as there seems to be a new Windows 10 policy of overwriting boot info on minor updates.

answered Jun 2, 2019 at 0:47

timbo's user avatar

timbotimbo

3231 gold badge4 silver badges14 bronze badges

2

It turns out grub can be fixed from Windows too. Running the following (as administrator) from CMD brought the grub menu back for me.

bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi

answered Oct 8, 2020 at 15:14

mindlessgreen's user avatar

1

Windows does not see Linux formatted partitions. You need to use gparted from a liveCD and create a primary partition formatted NTFS with the boot flag.

Some have had issues if the new primary partition is after the extended partition as Windows does not always reset partition table correctly. Best to have good backups and a separate backup of partition table.

Backup partition table to text file & save to external device.

sudo sfdisk -d /dev/sda > PTsda.txt

This is only for MBR (msdos) systems. If your Ubuntu install is in GPT partition drive you can only install Windows in UEFI mode or convert drive back to MBR (msdos).

wjandrea's user avatar

wjandrea

14.1k4 gold badges48 silver badges98 bronze badges

answered Jul 30, 2013 at 20:01

oldfred's user avatar

oldfredoldfred

11.8k3 gold badges23 silver badges33 bronze badges

2

Only fsck command fixed the grub-rescue screen for me.

Use Boot-Repair to boot from Live-CD, then open Terminal

Get the correct device:

sudo fdisk -l

Need to find the boot device, the boot device has * under Boot category like here:

Device     Boot   Start       End   Sectors  Size Id Type
/dev/sda1          2048   2000895   1998848  976M 82 Linux swap / Solaris
/dev/sda2  *    2000896 943716351 941715456  449G 83 Linux

Now repair the disk by using:

sudo fsck /dev/sda2 -y

Note: /dev/sda2 is the boot device in this example.

Reboot when completed. Done.

answered Jul 25, 2018 at 7:51

Benny's user avatar

BennyBenny

4,8002 gold badges19 silver badges33 bronze badges

I had a different issue, caused (probably) by boot-repair wiping my /etc/grub.d/ templates, outlined in my question here: Ubuntu 18.04 not booting after Windows 10 install

As pointed out by @karels comment, the grub config is generated using the files in /etc/grub.d. My directory only contained /etc/grub.d/25_custom, which contained strange menu entries pointing to non-existent .efi images. It looked like my /etc/grub.d templates were maybe hosed by boot-repair.

I fixed this by:

  1. Boot with Live CD (probably important to use same Ubuntu version)
  2. sudo mount /dev/sdxx /mnt
  3. sudo cp /etc/grub.d/* /mnt/etc/grub.d/
  4. sudo update-grub
  5. Reboot & relax after 48 hours of pain

answered Aug 29, 2019 at 9:58

Adam Moore's user avatar

You must log in to answer this question.

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

.

Contents

  1. Using the Ubuntu CD (Recommended)

    1. The graphical way
    2. The terminal way
  2. Using the Ubuntu Alternate CD
  3. See also

This page documents how to restore or recover the boot-loader (GRUB) after installing Windows. Some reasons to repair your boot-loader might include installing Microsoft Windows after you have installed Ubuntu, adding or removing a hard drive, or changing hard drive settings.

Note: this tutorial does not apply if you had installed Ubuntu inside Windows (via the Wubi installer). In this case, please read this page.

Using the Ubuntu CD (Recommended)

The graphical way

  • Insert your Ubuntu CD, reboot your computer and set it to boot from CD in the BIOS and boot into a live session. You can also use a LiveUSB if you have created one in the past.
  • Install and run Boot-Repair

  • Click «Recommended Repair».
  • Now reboot your system. The usual GRUB boot menu should appear. If it does not, hold Left Shift while booting. You will be able to choose between Ubuntu and Windows.

The terminal way

* Open a terminal. As of Ubuntu 11.10 and 11.04, this can be done by opening the Unity Dash (you can click the Ubuntu logo in the top panel or use the Windows key on your keyboard) and typing in «Terminal», and clicking what comes up. On earlier versions, you can achieve this by going to Applications -> Accessories -> Terminal. Alternately use the Keyboard Shortcut: CTRL + ALT + T.

For full details on using terminal to fix grub on hard drive from Live Installer DVD or Flash: https://help.ubuntu.com/community/Grub2/Installing#via_the_LiveCD_terminal

  • You are then presented with a standard bash prompt, type — this only works to reinstall to MBR of a working system:
sudo grub-install /dev/XXX

where XXX is the device of your Ubuntu install. (eg: grub-install /dev/sdb). Hint: You can also use /dev/disk/by-label/ if the partition you installed on has a label. You can determine the /dev node for such a device by running:

ls -l /dev/disk/by-label/

This will give the output of something like:

lrwxrwxrwx 1 root root 10 Oct 16 10:27 data -> ../../sdb2
lrwxrwxrwx 1 root root 10 Oct 16 10:27 data2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Oct 16 10:27 fat -> ../../sda6
lrwxrwxrwx 1 root root 10 Oct 16 10:27 home -> ../../sda7
lrwxrwxrwx 1 root root 10 Oct 16 10:27 root -> ../../sda1
lrwxrwxrwx 1 root root 10 Oct 16 10:27 swap -> ../../sda5
lrwxrwxrwx 1 root root 10 Oct 16 10:27 windows -> ../../sdb1

You can also use fdisk if you do not see the /dev/disk/by-label:

$ sudo fdisk -l

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001bc54

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       18725   150403072   83  Linux
/dev/sda2           18725       19458     5884929    5  Extended
/dev/sda5           18725       19458     5884928   82  Linux swap / Solaris

From here, find only the drive name, ignore the partition number, that is, for partitions labeled «root», «data2», «fat», «home» and «swap» it’s all still just sda. This is due to the fact that GRUB is installed in the MBR of the drive, and not on a partition.

Trouble? If other things are messed up, e.g. if you have deleted the partition from where Grub was previously installed, grub-install may return an error message such as «cannot find a device for /… (is /dev mounted?)». You may have to do grub-install a bit differently. Refer to the handy guide on fixing a broken system

Now reboot your system. The usual GRUB boot menu should appear. If it does not, hold Left Shift while booting. You will be able to choose between Ubuntu and Windows.

Using the Ubuntu Alternate CD

  • Boot your system from the Ubuntu Alternate CD.
  • When the Ubuntu splash screen comes up with the boot: prompt, type in rescue and press enter.

  • Choose your language, location (country) and then keyboard layout as if you were doing a fresh install.
  • Enter a host name, or leave it with the default (Ubuntu).
  • At this stage you are presented with a screen where you can select which partition is your root partition (there is a list of the partitions on your hard drive, so you are required to know which partition number Ubuntu is on). This will be dev/discs/discY/partX, where the X is a partition number and Y is the number of the drive.

  • Now proceed as described in «The terminal way» above.

See also

  • GRUB2


CategoryLive CategoryBackupRecovery CategoryBootAndPartition CategoryInstallation CategoryBootAndPartition

RecoveringUbuntuAfterInstallingWindows (last edited 2015-01-27 14:44:04 by iburst-41-56-112-193)

Если вы используете на своем компьютере две операционные системы, Windows и Linux, и обновили свою Windows из 7, 8 или 8.1 до самой новой Windows 10, могут возникнуть проблемы с загрузчиком Grub при использовании защищенной загрузки UEFI.  Во время обновления Windows 10 просто затрет загрузчик Grub и запишет туда свой.

Вы, как обычно, перезагружаете систему и ожидаете увидеть меню выбора операционной системы Grub, но вместо этого загружается новая Windows 10. Вам может показаться, что нет никакого способа получить доступ к Ubuntu или что не может работать Ubuntu рядом с Windows 10. Но это не так.

Многие советуют установить Ubuntu на другой диск, но есть более простое и прекрасно работающие решение, чтобы восстановить grub после установки windows 10. Кончено, всегда можно восстановить grub2 стандартным способом, с помощью LiveCD диска, но если вы используете UEFI, есть более легкое решение, мы сделаем все с помощью Windows 10.

Хотя за основу в этой статье берется Ubuntu, но это также будет работать и для других дистрибутивов. Просто папка, в которой находятся файлы загрузчика будет немного отличатся.

Шаг 1. Запуск cmd

Кликните по иконке поиск в Windows, наберите там cmd и найдите Командную строку Windows. Кликните по ней правой кнопкой и выберите Запустить от имени администратора:

Шаг 2. Подключение раздела EFI

Далее вы можете попытаться угадать как называется файл загрузчика Grub на разделе EFI, но можно поступить по другому и просто посмотреть. Чтобы подключить раздел EFI запустите diskpart. Для этого выполните:

diskpart

Затем выведите список доступных дисков:

list disk

Выберите в качестве активного диск, на который установлена Windows 10 и на котором сейчас находится раздел EFI:

sel disk 0

Далее выведите список разделов на диске:

list vol

Найдите раздел EFI, он обычно отформатирован в файловую систему FAT и занимает около 100 мегабайт места. В данном случае это том 2:

Этому разделу надо присвоить букву. Для этого выполните:

sel vol 2
assign letter=I:

Шаг 3. Поиск загрузчика

Далее надо найти файл загрузчика на разделе EFI. Но открыть этот раздел в проводнике вы не сможете, надо использовать только командную строку. Закройте DiskPart и выполните:

cd /d I:

Затем с помощью команды dir найдите загрузчик Grub. Например:

dir EFI\Ubuntu

Здесь есть файл grubx64.efi. Это он. Загрузчик может называться по другому в других дистрибутивах, именно поэтому я рассказал как всё посмотреть.

Шаг 4. Восстановление Grub

Скопируйте и выполните эту команду:

bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi

Вам не нужно будет вводить пароль, у вас уже есть права администратора и программа должна отработать нормально. Эта команда обратно запишет вместо загрузчика Windows 10 загрузчик Grub.

Если команда вернула ошибку, вы можете откатить изменения с помощью следующих команд:

bcdedit /deletevalue {bootmgr} path \EFI\ubuntu\grubx64.efi

bcdedit /set {bootmgr} path \EFI\Microsoft\Boot\bootmgfw.efi

Выводы

Восстановление Grub после Windows 10 завершено. Перезапустите компьютер и вы увидите на экране знакомый Grub. Надеюсь, эта краткая инструкция помогла вам выполнить восстановление Grub после установки Windows 10.

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

Об авторе

Основатель и администратор сайта losst.ru, увлекаюсь открытым программным обеспечением и операционной системой Linux. В качестве основной ОС сейчас использую Ubuntu. Кроме Linux, интересуюсь всем, что связано с информационными технологиями и современной наукой.

This is an operating system loader that is used in many Linux distributions. It is one of the most popular boot loaders for Linux and provides support for many operating systems.

When is recovery needed?

Grub recovery is required in the following cases:

  1. Installing a new operating system: when installing a new OS (for example, Windows) it can erase or change the grub bootloader, which may lead to the fact that you will not be able to boot into other operating systems on your computer. Grub recovery will help restore the ability to select and boot other operating systems.
  2. Updating or deleting grub: In some cases, updating or deleting grub may cause problems that may cause your computer to not boot. Grub recovery will help to fix these problems and return the system to normal boot.
  3. Changing hard disk partitions: If you have changed partitions on the hard disk (for example, created a new partition or resized an existing partition) without using the appropriate tools, this can also lead to the loss of the grub bootloader. Grub recovery will restore the ability to boot operating systems on your computer.

Grub recovery allows you to restore the normal functionality of the bootloader and restore the selection and loading of operating systems on your computer. It should be noted that grub recovery instructions may vary depending on the operating system used and the configuration of your computer.

How to restore grub?

Grub Recovery Instructions:

  1. Boot using a LiveCD or Live USB drive. You must have the same version of Linux installed as on your computer.
  2. Open a terminal and run the following command to find the partition containing your Linux installation: sudo fdisk -l
  3. Pay attention to the partition marked as «Linux» or «Linux LVM».
  4. Mount the Linux partition on your system. Suppose it is located in the /dev/sda1 partition. Run the following command to mount the partition: sudo mount /dev/sda1 /mnt
  5. Install several necessary packages. Run the following command: sudo apt-get install grub2-common grub-pc
  6. Restore grub. Run the following command: sudo grub-install —root-directory=/mnt /dev/sda
  7. Run the grub update. Run the following command: sudo update-grub
  8. Mount the Linux partition. Run the following command: sudo umount /mnt
  9. Reboot and check if grub is restored.

This is a basic instruction. Depending on your specific situation, you may need additional steps or commands. If you have any problems or errors, it is recommended to consult the official documentation of your Linux distribution or search for additional information on the Internet.

Recovery after Windows 10

If you are using UEFI and want to restore grub after installing Windows 10, there is an easier solution.

Here is a step-by-step instruction:

Start Windows 10 and open a command prompt with administrator rights. To do this, press Win + X and select «Command Prompt (Administrator)».

At the command prompt, run the following command to disable Fast Startup in Windows 10:

powercfg /h off`

Now run the following command to see the list of partitions on your computer:

diskpart

At the Diskpart command prompt, run the following command to find out the number of the partition where your Linux system is installed. Pay attention to the partition size (in GB) and the file system label to find the correct partition. Write down the partition number, you will need it in the next step.

list volume

Now run the following command on the command line to restore the GRUB loader to the selected partition (partition number_):

bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi« or«bcdedit /set {bootmgr} path \EFI\pop_os\GRUB.ext

(depends on your distribution).

Restart your computer. Grub should now be restored and you will be able to select your Linux system in the boot menu.

This is a simpler solution that allows you to restore grub using Windows 10 and without having to use LiveCD or other tools. Please note that in some cases additional configuration or more complex actions may be required.

  • Reset windows password скачать бесплатно на русском c ключом активации torrent
  • Restore backup windows server backup
  • Reset windows password полная версия скачать
  • Release date of windows 11
  • Repair windows defender windows 10