Linux restore windows boot

How to restore Windows boot loader after removing Ubuntu

I am just about to install Ubuntu alongside Windows, just need to make sure I know how to remove it later. I know from past the major problem was when I removed Ubuntu, I either still got into the GRUB booting menu, or I couldn’t boot at all, and had to format HDD and start over. Now I found an article practically saying the Windows loader should be back upon deleting Linux partition, so I want to make sure: If I have Windows and Ubuntu dualboot, and I want to get back to Windows booting quickly itself without choosing from any booting menu, is it enough to just delete the Ubuntu partition? Will the Windows loader override GRUB? Thanks!

3 Answers 3

This depends on whether your operating systems are installed in UEFI mode or Legacy mode.
(If your PC is manufactured in the last 5-6 years, and came pre-installed with an operating system, it will most likely be UEFI.)
There is a similar question that you can follow to check whether you are using Legacy or UEFI.

Note: Irrespective of which mode you install in, if you simply delete the Ubuntu partition, it won’t make the Windows bootloader default automatically. You have to do it once, manually.

If you install in Legacy mode and then delete the Ubuntu partition

You’ll most likely end up in a grub rescue prompt on the next boot. You’ll need a bootable recovery disk (either Windows or Linux) to help you restore your Windows boot sector.
Here is a similar question that can help in this case.

If you install in UEFI mode and then delete the Ubuntu partition

You’ll most likely end up in a GRUB command line prompt on the next boot, from where you’ll have to boot to Windows and delete the GRUB EFI Firmware entry or change the order to put the Windows bootloader in the first place.
Here is a similar question that can help in this case.

So, what’s the better way?

For Legacy

Boot to Windows first and use the bootsect tool to replace the GRUB boot sector with the Windows boot sector, and then delete the Ubuntu partition. Run these from an elevated Command Prompt :-

bootsect /nt60 SYS /mbr bootsect /nt60 SYS 

For UEFI

Manually delete the GRUB EFI boot entry and/or set the Windows bootloader to the first position before you get rid of Ubuntu.
This answer to a similar question explains the process for deleting it in Windows.

Читайте также:  Destination host unreachable linux vmware

To perform this from Ubuntu, the efibootmgr tool can be useful. Run :-

to see the entries currently in your bootloader, then run :-

Источник

RecoveringUbuntuAfterInstallingWindows

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.

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.

  • You are then presented with a standard bash prompt, type — this only works to reinstall to MBR of a working system:

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:

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.

Читайте также:  Аналоги vnc для linux

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

RecoveringUbuntuAfterInstallingWindows (последним исправлял пользователь iburst-41-56-112-193 2015-01-27 14:44:04)

The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details

Источник

Restore windows boot manager in grub command line

So I installed GRUB2 and Ubuntu 14.10 alongside Windwos 8.1. I am on an Acer laptop, which does not have a cd drive. I deleted the Ubuntu partition in windows 8.1 through the integrated disk manager, restarted and now am seeing this:

GNU GRUB version 2.02~beta2-9ubuntu1 Minimal BASH-like editing is supported.for the first word, TAB lists possible commands completions.Anywhere else TAB lists possible device or file completion grub> 

I have googled some things and I think I need to restore the default Windows boot manager. However, I don’t have a recovery disk for windows 8.1, and again, I don’t have a cd drive. Is another possibility to make a usb with Ubuntu on it and to boot this one instead and then somehow to fix this?

Читайте также:  Копирование файлов через cmd linux

Yes. it is possible to do USB of Ubuntu and fix it that way, but I think my answer might be more beneficial. If it doesn’t work then let me know and I’ll show you a different way.

The ideal solution would be to boot into Windows, and then restore the Windows boot manager. Lets start with booting Windows. What you can do is put Super Grub2 on a USB drive and boot from it. See supergrubdisk.org. It has an «everything» option which should detect Windows and allow you to boot it. Once you get that working, we can work on the Windows boot manager.

5 Answers 5

I write «exit» then enter. The menu of Boot Manager shows, then I select Windows Boot Manager. It works with Windows 10

In my practice, I follow this video’s guide to recovery windows boot manager from grub.

Firstly, make a linux os (like ubuntu )bootable usb stick, plug into the PC, and boot from usb, enter live mode;

Thirdly use lilo to make master boot record of your disk partition.

Then should the computer boot from windows.

For me, «exit» did not work. I had to find my EFI partition by entering in the grub command line (from here):

grub rescue> ls (hd0,4) (hd0,3) (hd0,2) (hd0,1) grub rescue> ls (hd0,4)/boot . some kind of 'not found' message grub rescue> ls (hd0,3)/boot . some kind of 'not found' message grub rescue> ls (hd0,1)/boot . grub . initrd.img-2.6.32-33-generic . vmlinuz-2.6.32-33-generic 

So, for (hd0,1) I had to enter at the grub rescue prompt: (from here):

insmod part_gpt insmod chain set root=(hd0,1) chainloader /EFI/Microsoft/Boot/bootmgfw.efi boot 

This brought me to the windows boot management. From there, I followed other advices to restore the windows boot manager to appear at startup. Important, because it was not my machine. In the end, I had to reformat the EFI partition and restore its content with the » bcdboot » command from a windows RE, because I had no access to that partition to use » bootrec /fixboot » (see here, in German).

Thank you, all you contributers!

Источник

Оцените статью
Adblock
detector