I had dual-booted my Win7 computer with Ubuntu 12.04 a few months ago, but no longer wanted Ubuntu so I deleted that partition using Windows last night. When I booted my computer this morning a black screen came up that said:

error: unknown filesystem

Entering rescue mode...

grub rescue>

The available filesystems are:

(hd0) (hd0,msdos5) (hd0,msdos4) (hd0,msdos2) (hd0,msdos1) (hd1)

I tried looking online and everywhere but it kept on saying to use the Windows 7 installation CD to boot into that and choose "Repair Windows" or something like that. However, I don't have the installation CD because the computer I bought didn't come with it.

So I guess what I'm asking is (1) How do I get into Windows 7? (2) How do I get it so that grub rescue never appears again? (3) Why did it appear just now?

  • Exactly how did you "delete" the ubuntu partition (e.g. what command)? Commented Dec 12, 2015 at 23:20
  • I went into Disk Management and removed the partition that Ubuntu was on. It then said "Free Space" instead of "Unallocated" but I didn't think much of it. Somewhere online told me to do that.
    – Kyle Neary
    Commented Dec 12, 2015 at 23:27
  • This looks promising (never used this way myself, so please be very cautious). Good luck!
    – vlp
    Commented Dec 12, 2015 at 23:59

2 Answers 2


You have a serious problem

You'll need to take great care when proceeding.

When you deleted the partition, you destroyed the data that grub uses to configure itself. That's why you got rescue mode.

It's not about "getting rid" of the grub rescue prompt but is about repairing the damage you did to your system when you altered the partition without fully realizing the implications. Using a windows utility to do this didn't help matters, either.

Restoring your system to a correct state will take some time, patience, and, as I said, care. It's a process with multiple steps, so brace yourself ...

Backing up windows

The first step is to get a backup of all your windows partitions. If windows were booted [and I realize you can't yet--we'll get to that below], windows has a standard backup program. It can create a "system recovery disk", which is a bootable CD/DVD. After creating that, you can use backup to create a "system image" and backup all file data onto a separate USB hard drive. Be sure to enable enough options to create the system image and back up all your partitions.

With both of those, you can fully restore a blown windows partition [you don't have one yet, but ...]. The combo can serve as a installation disk for windows that reimages everything with the latest data you had.

This is a critical step. Do not attempt to "repair" anything before you've done this. You have been warned.

Booting windows automatically

There may be a quick and easy way, if you're lucky.

If the grub.cfg file is intact, grub may have been working normally. That is, the boot menu was available but you didn't hit a key to override, and after the timeout period, grub did the default boot, which was ubuntu, and couldn't find/use it.

If you override [hit any key--spacebar recommended], you will get a menu and can select windows boot [usually at the bottom]. With a short timeout value, you may have to be very quick and try this multiple times.

If you're able to do this, things can be a lot simpler.

Booting windows manually

If the above didn't work ...

You'll have to boot windows manually from the grub rescue prompt. You'll have to enter some detailed commands.

The first step is to determine which device to use from the list you gave. At a guess, I'd say (hd0,msdos1). This is particularly true if you installed windows before ubuntu or windows came pre-installed.

Note that the above is a guess. The definitive way is to create a livecd of gparted [or possibly use your ubuntu livecd] to get a list of the partitions with filesystem types. This should give you a clue as to the correct device.

It wouldn't hurt to write down [or print] this partition information on paper for later reference.

But, you could just try a boot with the guess--caveat emptor.

Sample grub commands

Here is a sample grub.cfg snippet from my system for chainloading to windows. The AABCC56FBCC5369B is a uuid specific to my system, so ignore that.

menuentry 'Windows 7 (loader) (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-AABCC56FBCC5369B' {
    insmod part_msdos
    insmod ntfs
    set root='hd0,msdos1'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  AABCC56FBCC5369B
      search --no-floppy --fs-uuid --set=root AABCC56FBCC5369B
    chainloader +1

The relevant commands to be entered manually are:

insmod part_msdos
insmod ntfs
set root='hd0,msdos1'
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'
chainloader +1

You may have to fool around with the options a bit. You may need insmod part_gpt instead of insmod part_msdos

As should be obvious, you may need to adjust hd0,msdos1 to one of your other disks.

Once windows has booted, go back to the previous step and take a backup.

Note: Record the commands [that finally work] on paper. You may have to reenter them.

I'd recommend ignoring any requests by windows to perform updates as you'll [probably] have to reenter the boot commands here when windows requests a reboot.

Repairing the boot

Once again, do not try this until you have a windows backup.

The above methods to boot windows, just allowed windows to be booted once. They did not repair anything related to the boot. If you power off your system or reboot, the above boot steps would have to be repeated.

It is unclear to me what exactly happened when you deleted the partition. Did you simply remove it from the partition table [meaning the space it occupied is now listed as free] or do you also move partitions higher up on the disk to occupy the space of the old partition [something that gparted can do]?

If you were able to use the automatic boot process above, you can simply edit /boot/grub2/grub.cfg and change the set default="0" to point to the windows boot [menu entries are numbered from 0]. This can be done from the ubuntu livecd. You get a shell and your hard drives should be [or can be] cross-mounted under [e.g.] /mnt/sysimage/...

If you had to boot manually, you may be able to boot the ubuntu livecd, get the shell, and run grub2-install on the cross-mounted hard drive. You may need to use other grub2-* utilities. For this, you really should consult detailed grub2 documentation. And, for you, I don't necessarily recommend this.

A simpler, easier way, may to be to use the ubuntu livecd to reinstall ubuntu [temporarily]. This will handle the grub reinstall. You can then boot ubuntu from your hard drive as before and edit /boot/grub2/grub.cfg to change the default.

If, when deleting the partition, if you did a "move", you may have to reverse that operation. Don't do this [or any such operations, IMO] under windows. Use gparted

The /boot partition

On some systems/distros, most usually, /boot resides on its own small partition that is ~2GB or so. That's the standard [and, IMO, recommended] way.

Because you got a grub rescue prompt, that's probably what you have. That's the easy way.

Less likely, but still possible [particularly if you overrode the default], /boot may merely be a directory under the root partition. But, if that were the case, I don't believe grub would have come up at all--YMMV

With a small, separate /boot partition, you can afford to shrink/remove the large ubuntu partition [again] but use a credible tool like gparted. More on this below.

Restoring the boot [alternate]

If you're lucky enough to have the small /boot partition, I recommend leaving grub as the boot loader, even if it only boots windows.

With only the large root partition, you may want to restore windows boot. I do not recommend this for you, based upon your current system state.

There may be a windows based method to do this, which should be easy enough from a booted windows. But, I would have the repaired grub boot going first, as windows likes to reboot during such operations.

How to get windows to do this is beyond my expertise.

If you've got grub running from a large root partition, you can remove most files that are not in /boot.

After that, using gparted, you can shrink the root partition. gparted is smart enough to be able to change all the filesystem index blocks, etc. to maintain integrity. It will also adjust the partition table.

This gives you free space, and gparted can create another partition with the free space, which you could use as a windows (e.g.) D: drive


If you have about 16GB of free unallocated space, or an unused partition about that size or bigger which you can format (ok to delete its contents), might work with a bit less than that size also, then this answer is for you.

I deleted the ubuntu partition because I needed more space on the windows partition; I did this using Create and format hard disk partitions in windows - just click on start menu and type part; resizing of windows partitions should be done only from windows to avoid issues; so I resized the windows partition with a few extra GB;

luckily, I did not give all the free space that was left after deleting the ubuntu partition to windows;

so when I got the grub rescue error, upon the next reboot, the ls and set grub commands worked, but several other commands like chainloader, initrd or normal did not work; the problem was that although I did do a shutdown, windows tries to be smarter and second guess you and do a hibernate anyway, to enable a faster boot next time; so the disk was in a "dirty" inconsistent state and therefore could not be mounted, except in read-only mode which does not allow fixing anything, even using a live ubuntu usb drive, and therefore, could not fix/reinstall grub from the live ubuntu; this of course also means that windows cannot be started from grub; and naturally, the os-prober command from linux cannot find the windows system in this state either, not that it matters;

in my case, as I had free space available, I created a partition from linux, with the ubuntu live usb installer - without touching the windows partitions - and also created a new EFI partition for grub and sized it to 128MB for good measure, and installed ubuntu into the new partition using the live usb installer; it installed fine - but at the end it failed to install grub - because the windows was hibernated/dirty

so for this, I used the live ubuntu usb and installed boot-repair as follows at a terminal (ctrl+alt+t to open a terminal in ubuntu) (this is installed only in memory, not on disk, as it is a live ubuntu usb, so if you reboot, you need to redo these steps below):

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

then I ran boot-repair and selected the first option:

sudo boot-repair

this showed the commands to type to remove the old grub and install a new one into the EFI partition created above; then it was possible to boot in the newly installed ubuntu, using the new grub in the new EFI partition;

then in ubuntu at the terminal prompt I typed

sudo update-grub

and now the windows was also added to the grub menu and everything works again, upon the next reboot both ubuntu and windows can now be selected in the grub menu

apparently to shut down windows without the dirty hibernation, need to type at a windows command prompt

shutdown /s

You must log in to answer this question.