Restore Grub After Windows Install

Posted on by admin

Usually when we install Windows after installing GNU/Linux, we usually lose the Grub. Which is the best way to recover grub when we lost grub or what are the possible different ways. Ubuntu debian grub2 gnu. May 24, 2018 So, finally, I upgraded Windows 8.1 to Windows 10 last night. Since I dual boot Windows 8.1 with Ubuntu, I was expecting to see the Grub menu at boot so that I could choose the operating system I wanted to use. But the upgrade to Windows 10 from Windows 8.1 messed up the settings and it never showed the grub menu.

Back in the days when floppy disks were still being commonly used, flashing your motherboard’s BIOS could only be done by booting the computer into DOS. When DOS is booted up on the computer, you’d probably have to switch to the floppy disk that contains the BIOS update file. Unlike today where updating a modern BIOS is far easier and convenient and you can update the BIOS directly from Windows using the software provided by the manufacturer, or simply put the BIOS file onto a USB flash drive and the inbuilt flashing tool inside the BIOS will recognize it.

If for some reason the software provided by the motherboard manufacturer is broken and you’re not able to update the BIOS from Windows, or your BIOS doesn’t actually support flashing from any other medium apart from a floppy drive and DOS, you can still do it from DOS by booting up the computer with a USB flash drive instead of a floppy which is far easier. The most popular and easiest ways are to simply install MS-DOS or FreeDOS onto the USB drive, copy over the required BIOS file and flashing utility from the manufacturer’s website, boot to USB and flash the BIOS from there.

Jan 24, 2020 'Postrequisites' - after installation: how to restore the USB stick to a standard storage drive. The standard is an MSDOS partition table (MBR) and a partition with the FAT32 file system. Until yesterday I had a dual boot debian / win8 with grub that worked like a charm. Yesterday a stupid windows update totally wiped grub and I'm now unable to boot in linux. I installed linux a year ago and I remember it was quite a pain to properly make grub work and I don't even remember all the steps involved. We install the GRUB2 in the MBR (the partition where Windows is located): # grub2-install -recheck /dev/sdb Installation finished. No error reported. # grub2-mkconfig -o /boot/grub2/grub.cfg Finally, get out of Chroot and restart the system naturally: # exit exit.

Thankfully, there are tools around that can help you accomplish this with the minimum of effort, and not lead you through a huge multiple step process full of manual commands. Here are 5 such tools that will put either FreeDOS or MS-DOS onto a bootable USB flash drive allowing you to update the BIOS firmware from DOS but without a floppy drive.

1. Rufus

Rufus is a small utility that helps format and create bootable USB flash drives, such as USB keys/pendrives, memory sticks, etc. It’s also a useful tool to help install different versions of Windows via USB and can also check USB devices for errors. It is a small, single and self contained portable executable file and the user interface resembles the Format tool in Windows.

Rufus has the added bonus of giving you the choice of installing either FreeDOS or MS-DOS onto USB for BIOS flashing. Simply plug the USB flash drive into your computer, run Rufus, select the device that you want to install DOS onto, make sure the file system is FAT32, check there’s a tick next to “Create a bootable disk using:” and select either FreeDOS or MS-DOS from the drop down menu. Finally click the Start button. Rufus used to come with a separate version for FreeDOS support, but it’s now integrated as standard

2. WinUSB Maker

WinUSB Maker is by Josh Cell Softwares who produce some very useful Windows tools such as Advanced Tokens Manager and WinOwnerShip, and this tool can install the setup files for Windows XP up to Windows 8 setup onto USB, install the GRUB loader onto USB, create a full backup and restore of USB devices, and also do what we’re looking for, install MS-DOS onto a USB stick.

Like the other tools, WinUSB Maker is a standalone tool (although it does require the .NET Framework version 4 to run), simply launch it after inserting the USB drive and select it from the drop down in the Welcome screen. Then click on MSDOS to USB down the left and click the “Make USB Bootable” button, and accept the data will be lost warning. After a few seconds, you’ll have a DOS USB ready for the BIOS files.

12Next › View All

You might also like:

10 Tools To Install Windows Faster Using a USB Flash DriveHow to Downgrade a Phoenix BIOS using WinPhlashHow To Easily Put Hiren’s BootCD on to USB Pen StickHow To Make a USB Flash Drive Bootable3 Ways to Install and Run Kaspersky Rescue Disk from USB Flash Drive

On UEFI motherboards, to boot into FreeDOS, you need to activate the Compatibility Support Module (CSM), which enabled BIOS features in UEFI. Also, in Secure Boot options, select “Other OS”.

If you installed Windows while in UEFI mode, don’t forget to revert the aforementioned UEFI settings back, before you reboot into Windows, to prevent unpredictable problems.

Gregg Eshelman4 years ago

Doesn’t look like any of these can format the USB drive to pretend to be the A: drive. That’s a requirement on some systems like certain thin clients. If you boot from USB with a device that assumes the C: drive, they won’t allow anything to touch their internal storage. That’s usually an IDE (2.5″ connector) or SATA Disk On Module. A DOM is like a SSD but generally made with chips not meant to be written to umpty-thousand times.


It works all over my computer. Thanks Ray.


Leave a Reply

Site Index • Wiki • Blog

GRUB and Master Boot Record

Web lore indicates that Windows is not friendly when installedafter/over Linux. Linux should normally installed after Windows ina dual-boot system, because it's niceenough to leave the system set up to dual boot into both. Installing Windows second sort of destroys Linux bootcapability.

This document describes how to put GRUB (GRand UnifiedBootloader) back on a hard drive that has beentaken over by a Windows 2000 install, which itself was installed afterLinux, which was installed after Windows XP. Thecritical concept is how to put GRUB back on the Master Boot Record,which is taken over during a Windows install. Bibliography andadditional references are at the end.

Mandriva Linux vs.Windows XP

My daughter's laptop computer at college crashed. Ihad theWindows XP install CD-ROM, and the plan was to send it to her and talkherthrough the installation. To be sure I had the step-by-stepinstructions memorized, I used the CD to install Windows XP ona local hard drive first, while writing down each step. I also wanted toinclude a MandrivaLinux Operating System on the same hard drive, so Idirected the WindowsXP Pro installprocess to only use the first 10 GB of the hard drive.

During the install process, Windows XP refused to fullyregister.When it contacted Microsoft over the Internet, their databaseproperly knew that this operating system was licensed to run only on mydaughter's laptop. So, I knew I only had 30 days to use XP. But that was no problem because the main reason to installit was accomplished. I intended normal work to be done on thissystem using Linux,allowingthe first 10 GB to be a play partition where I could re-install WindowsXP if I wanted, or eventually let Linux have it.

In order to put Linux on the rest of the drive (beyond the first 10 GB), I had to getinstalldisks. Normally, a person could download the MandrivaInstall CD-ROM Image(s) andinstall from a CD-ROM. Interested in doing somethingdifferent with my 250 Kbit/s Internet link, I decided to download thesmall, bootable Mandriva Network Install CD-ROM. Doingthe network install downloads the applications only if you select them. Of course, the down-side is that you have to have areasonably fast internet available during the installation procedure.The 2006MandrivaNetwork Install CD-ROM image for anormal PC computer is only 26 MB, so it fits nicely on asmall 50 MB CD-ROM, and initiates the install process.

During install, the Mandriva sequence allowed me to createpartitions on the four primary partition table entries of /dev/hda:

0 10 GBWindow (leave it as is)
00 6 GBLinux root filesystem
400 MB Linux swap space
0 60 GBLinux home filesystem

I chose the GRUBboot program and the Gnome deskstop, and havebeen pleased with both.

The GRUB loader is nice because the piece of code that isactually writtenon either the Master Boot Record of the drive or on the Boot Sector ofa partition, is static. It's smart enough to reach onto aLinux filesystem and read the rest of the files it needs to operate. One of these files is the the /boot/grub/menu.lstfile, which lets GRUB know what operating systems are available to boot.

TheGRUB bootloader is often compared to the LILO bootloader,which reads itsconfiguration file at install time, and puts a piece of code on thedisk drive that goes directly to the right files based on lower-levelsector and track mapping. LILO is a little more efficient,and in theory lets you pull a boot program off a hard drive formattedin any file system or not formatted at all. In practice, mostpeople pull the boot program from a Linux file system anyhow, so theyuse and enjoy the addition run-time options of GRUB. I've used LILO since 1994, and have just started using GRUBin the last year or so. Here's the GRUB configuration fileleft on my computer after the Mandriva install procedure:

color black/cyan yellow/cyan
default 0
kernel (hd0,1)/boot/vmlinuz root=/dev/hda2 resume=/dev/hda3
splash=verbose vga=788
initrd (hd0,1)/boot/initrd.img
kernel (hd0,1)/boot/vmlinuz root=/dev/hda2 resume=/dev/hda3
initrd (hd0,1)/boot/initrd.img
kernel (hd0,1)/boot/vmlinuz root=/dev/hda2 failsafe resume=/dev/hda3
initrd (hd0,1)/boot/initrd.img
root (hd0,0)
chainloader +1

Even to the unitiated, it's probably obvious that there arefour bootoptions, accessing partitions 0 or 1 on the first hard drive. The first three boot into Linux with various options, and thefourth boots into Windows.

Windows Writes over Linux Boot Sectors

Mydual boot Windows XP / Linux system I created worked great for a month. I knew it was time to make some changes when I tried to bootinto Windows XP, and as predicted, it refused to run because I had notregistered the copy.

So,I got out the original Windows 2000 disks for this computer, and did aninstall onto the 10 GB first partition of the hard drive. Asexpected from the non-friendly Windows, GRUB was written over, and Windows would boot only to Windows.

Putting Back Dual Boot: Mandriva Linux & Windows 2000

Windows 2000 and Mandriva Linux were both on the disk in their respective partitions. However, toput back the dual boot capability you'll have to boot Linux with somethingunrelated to this story. I used a bootable Gentoo LinuxMinimal/Install CD-ROM for the Intel x86 architecture,but I think I could have also used Tom'sRoot Boot Linux, which comes on a single bootable 1.44 MBfloppy. Research on the the Internet until you'recomfortableacquiring and booting one of those.

Once inside of the Gentoo boot Linux, mount up the Mandrivaroot partition:

mkdir mount-location
mount -t ext3fs /dev/hda2 /mnt/mount-location

In my Linux distribution there was an install script(named, of allthings) left in place that runs GRUB, which automates three grubcommands. Here's a copy of the script file:

grub --device-map=/boot/grub/ --batch<<EOF
root (hd0,1)
setup --stage2=/boot/grub/stage2 (hd0)

Drop into the GRUB directory previously created duringtheMandriva install and run the script, which will cause GRUB to re-writeover the Master Boot Record:

chroot/mnt/mount-location /bin/bash
cd /boot/grub

The chroot command changes the root directory of the file system being used. This allows me access to the GRUB program, theinstall scripts, and the other configuration files left on the Mandrivafilesystem rather than be stuck in the context of the Gentoo bootenvironment which knows nothing of what I'm trying to do. Also, the './' might be new toWindows users. Forsecurity and historical reasons, Linux will not automatically searchthe current directory for a program to run. The '.' directoryexplicitly directs the command processor to use the install.shscript found in the current directory.

Running the script should kick out a few lines of information.Poof! The Master Boot Recordis re-written with GRUB, and because the menu.lstfile mentioned above is already in place on the Linux partition file system, full dual-boot capability hasbeen restored. Here is the output I received from the scriptwhen it ran GRUB:

Linux Mint Restore Grub After Windows Install

Restore Grub After Windows Install

GNU GRUB version 0.97-19mdv2007.0 (640K lower /3072K upper memory)

[ Minimal BASH-like line editing is supported. For
the first word, TAB lists possible command
completions. Anywhere else TAB lists the possible
completions of a device/filename. ]
grub> root (hd0,1)
Filesystem type is ext2fs, partition type 0x83
grub>setup --stage2=/boot/grub/stage2 (hd0)
Checkingif '/boot/grub/stage1' exists... yes
Checkingif '/boot/grub/stage2' exists... yes
Checkingif '/boot/grub/e2fs_stage1_5' exists... yes
Running'embed /boot/grub/e2fs_stage1_5 (hd0)'... 15 sectors areembedded.
Running'install --stage2=/boot/grub/stage2 /boot/grub/stage1 (hd0) (hd0)1+15 p(hd0,1)/boot/grub/stage2 /boot/grub/menu.lst'... succeeded
grub> quit

I rebooted the computer using the exitand reboot commands. TheMandriva/GRUB boot selection screen Iremembered appeared. All is back to normal.

BTW, where the Windows 2000 Master Boot Record went?When running LILO,it saves a copy of the 512 byte sector it's about to write overinto a file called boot.0300 (assuming theMBR on the firstdisk) in the /boot directory. I believe GRUBdoes not do thisbecause I removed the boot.0300 file first,and it did not re-appearafter running the script. I think the Windows 2000 512-byte Master Boot Record was lost.

Bibliography / Additional Resources

Howto recover from 'grub-install /dev/hda1' - Reverse problem.Having accidently slapped GRUB onto a boot sector of apartition, this explains how to put the Windows boot sector back. I wasable to do this trivially with the ddprogramwhen I used LILO, because LILO savesa copy of the original boot sector before it writes into it. In myopinion, GRUB should do this, too. Emphasizes the difference betweenhda (MBR) and hda1 (boot sector of a partition).
Restore Grub After Windows Install

Install Grub From Windows 10

Windowsreinstall messes up grub - After re-installing Windows, thisuser wanted to get back a Ubuntu Linux boot option.
RecoveringUbuntu After Installing Windows- Uses Ubuntuspecific procedure, rather than generic procedure documented in thepage you're reading.

Restore Grub After Windows Install

Howto Repair a Corrupt MBR and boot into Linux - Sameaccomplishment, but slanted towarda Fedora Linux system. Includes LILO instructions. Includes Knoppixinstructions.

Revision1.1 - Thisdocument was originally created using AbiWord under theGnomedesktop. AbiWord has alot smaller footprint than OpenOffice and still does Wordcompatiblefiles. One problem: I saved the file as an.html file and when I went back to read it in, AbiWord could not readit. Hmm... I did subsequent editing with the Nvuweb page editor and the TextPadtext editor.