69

I have a multiboot system set up. The system has three drives. Multiboot is configured with Windows XP, Windows 7, and Ubuntu - all on the first drive. I had a lot of unpartitioned space left on the drive and was reserving it for adding other OSes and for storing files there in the future.

One day I went ahead and downloaded Partition Wizard and created a logical NTFS partition from within Windows 7, still some unpartitioned space left over. Everything worked fine, until I rebooted the computer a few days later.

Now I'm getting:

error: unknown filesystem.  
grub rescue>

First of all I was surprised not to find any kind of help command, by trying:

help, ?, man, --help, -h, bash, cmd, etc.

Now I'm stuck with non-bootable system. I have started researching the issue and finding that people usually recommend to boot to a Live CD and fix the issue from there. Is there a way to fix this issue from within grub rescue without the need for Live CD?

UPDATE

By following the steps from Persist commands typed to GRUB rescue, I was able to boot to initramfs prompt. But not anywhere further than that.

So far from reading the manual on grub rescue, I was able to see my drives and partitions using ls command. For the first hard drive I see the following:
(hd0) (hd0,msdos6) (hd0,msdos5) (hd0,msdos2) (hd0,msdos1)

I now know that (hd0,msdos6) contains Linux on it, since ls (hd0,msdos6)/ lists directories. Others will give "error: unknown filesystem."

UPDATE 2

After the following commands I am now getting to the boot menu and can boot into Windows 7 and Ubuntu, but upon reboot I have to repeat these steps.

ls
ls (hd0,msdos6)/
set root=(hd0,msdos6)
ls /
set prefix=(hd0,msdos6)/boot/grub
insmod /boot/grub/linux.mod
normal

UPDATE 3

Thanks Shashank Singh, with your instructions I have simplified my steps to the following. I have learned from you that I can replace msdos6 with just a 6 and that I can just do insmod normal instead of insmod /boot/grub/linux.mod. Now I just need to figure out how to save this settings from within grub itself, without booting into any OS.

set root=(hd0,6)
set prefix=(hd0,6)/boot/grub
insmod normal
normal

UPDATE 4

Well, it seems like it is a requirement to boot into Linux. After booting into Ubuntu I have performed the following steps described in the manual:

sudo update-grub
sudo grub-install /dev/sda

This did not resolve the issue. I still get the grub rescue prompt. What do I need to do to permanently fix it?

I have also learned that drive numbers as in hd0 need to be translated to drive letters as in /dev/sda for some commands. hd1 would be sdb, hd2 would be sdc, and so on. Partitions listed in grub as (hd0,msdos6) would be translated to /dev/sda6.

UPDATE 5

I could not figure out why the following did not fix grub:

sudo update-grub
sudo grub-install /dev/sda

So I downloaded boot-repair based on an answer from https://help.ubuntu.com/community/Boot-Repair post. That seemed to do the trick after I picked the "Recommended Repair (repairs most frequent problems)" option.

4
  • zdnet.com/… also has some helpful info on this subject.
    – K7AAY
    Feb 21, 2014 at 15:17
  • having similar problem, but in mine live USB is also useless goo.gl/Mr61V1
    – Ramesh
    Apr 23, 2016 at 4:45
  • Changing boot order, starting from the Windows 7 Recovery CD, starting terminal, typing "Bootrec.exe /FixMbr" (without quotes) and rebooting fixed my issue.
    – consuela
    Nov 26, 2016 at 16:15
  • In previous update3 worked for me, but now the same problem. Not working even i tried with listed folders in grub rescue. I have tried to back up data by using ubuntu ISO device, existing ubuntu not listing out. Help me what should i do now?
    – Jaccs
    Jan 8, 2018 at 5:43

6 Answers 6

27

I could not figure out why the following did not fix grub:

sudo update-grub
sudo grub-install /dev/sda

So I downloaded boot-repair based on an answer from Persist commands typed to GRUB rescue post. That seemed to do the trick after I picked the "Recommended Repair (repairs most frequent problems)" option.

I have also used Grub Customizer to customize the order of boot entries.

1
  • It didn't work because, after running the last command, you you would need to run sudo update-grub again. On a live session, you would need to mount the target filesystem to mnt, chroot into the filesystem and then you would need to run sudo update-grub from the chroot.
    – mchid
    May 28, 2016 at 11:27
9

Use:

  1. set prefix=(hdX,Y)/boot/grub. Use the values determined earlier.
    Example: If the Ubuntu system is on sda5, enter:
    set prefix=(hd0,5)/boot/grub
  2. set root=(hdX,Y). Example: set root=(hd0,5)
  3. insmod normal. Attempt to load the normal module.
  4. normal

We basically need GRUB to know where the /boot/grub folder is. If this is not working, I guess doing a GRUB install from a boot CD is a good option.

2
  • Thanks for your assistance. I think my problem may have been that my boot directory is on /dev/sdb, not /dev/sda. But boot-repair fixed it automatically, so I did not have to do anything further.
    – user53817
    Apr 15, 2012 at 2:52
  • Holy frijoles, this worked for me... I was able to use my hard drive salvaged from an ancient debian server to boot a vmware VM. But it wasn't saved through a reboot.
    – John Smith
    Nov 4, 2023 at 20:55
8

There is an alternative cause of this problem. In this particular case, GRUB was somehow corrupted and needed to be repaired or reinstalled. However, as shown in Grub rescue fails with "Boot Repair" with error "unknown file system", it's also possible that the root partition on which GRUB is installed could be corrupted. To fix this:

This is a possible solution, but it should not be used likely lest your root partition become further corrupted. Running the command fsck -t ext4 /dev/sda1, this program attempts to search and repair errors on a corrupted filesystem. Replace sda1 with your actual root partition. Replace ext4 with the actual filesystem; you have to know the file system or else the partition will be more corrupted. See Repairing a corrupted filesystem for more information.


Even though this question has an answer, there is an alternative way to fix the problem that worked for me. The steps are explained in the painful video Grub Rescue - Guide for beginners. In short, it will reinstall GRUB 2 altogether instead of repairing it.

Because this video is so painful to watch, I'll list the steps below (as I should regardless of how painful it is to watch the video)

  1. Launch a live session of Ubuntu. The video uses a live CD whereas I used a live USB. I made sure that the live USB had the same version of Ubuntu that I had on my harddrive.
  2. Find where your root partition was mounted. In the video, the user uses Nautilus to navigate through each drive that was mounted. It was mounted with a long string of numbers and characters. If this is the case, follow the following steps to remount the partition. Else, proceed to step 5.
  3. Bring up the terminal with Ctrl + Alt + T and use the mount command to find the name of the partition.
  4. Mount the partition. Create a new folder in your media folder. sudo mkdir /media/ubuntu. Then simply mount your partition to that folder. sudo mount /dev/sdxx /media/ubuntu where xx of sdxx is determined in step 3.
  5. Bind the following directories from the root directory of your live CD/USB to that of your root directory on your version of Ubuntu. The directories are the dev proc and sys. Do so with the following commands:

    sudo mount --bind /dev /media/ubuntu/dev
    sudo mount --bind /sys /media/ubuntu/sys
    sudo mount --bind /proc /media/ubuntu/proc
    
  6. Change the root directory to the one on your Ubuntu partition. sudo chroot /media/ubuntu/

  7. Having done the above, installing GRUB 2 again will install it to the root directory of your distribution of Ubuntu and not that of the live CD/USB's. So go ahead and run sudo grub-install /dev/sdx

And that's how to fix GRUB using a live CD/USB. This method was developed by YouTube user crazytechzone.

1
  • After chrooting, you are automatically root, so you don't need sudo. Just grub-install is good enough.
    – user43326
    Jul 22, 2020 at 7:35
4

Funny, I also had the same problem an hour ago!

Anyway, this is what I did.

  1. Load ubuntu:

    set root=(hd0,6)
    set prefix=(hd0,6)/boot/grub
    insmod normal
    normal
    

    since your ubuntu is installed in 6 right?

  2. run terminal:

    sudo -i *to access root*
    grub-install --root-directory=/mnt/ /dev/sda
    sudo update-grub
    sudo grub-install /dev/sda
    
1
  • Thanks for your answer, but I got my grub fixed using boot-repair tool before you posted the answer. I have now updated this post with my solution. I wish I could have tried your method as well.
    – user53817
    Apr 7, 2012 at 8:21
3

Install Boot-Repair in Ubuntu

  1. Boot your computer on a Ubuntu live-CD or live-USB.

  2. Choose "Try Ubuntu"

  3. Connect internet

  4. Open a new Terminal (Ctrl+Alt+T), then type:

    sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
    
  5. Press Enter.

  6. Then type:

    sudo apt-get install -y boot-repair && boot-repair
    
  7. Press Enter.

Using Boot-Repair

enter image description here

Recommended repair

  1. Launch Boot-Repair from either :

    a. The Dash (the Ubuntu logo at the top-left of the screen)

    b. Or System->Administration->Boot-Repair menu (Ubuntu 10.04 only)

    c. Or by typing 'boot-repair' in a terminal

  2. Then click the "Recommended repair" button. When repair is finished, note the URL (paste.ubuntu.com/XXXXX) that appeared on a paper, then reboot and check if you recovered access to your OSs.

  3. If the repair did not succeed, indicate the URL to people who help you by email or forum.

1
  • @penreturn Thank you so much, this worked wonderfully. :D
    – Jeel Shah
    Jan 26, 2013 at 21:15
0

Another cause of the problem is that the filesystem on the boot drive may be crashed in rare cases. As mentioned in other answers, I initially use the ls command to list all drives/partitions in the GRUB rescue prompt, but all report unknown filesystem error. I finally fixed the problem on Ubuntu 16.04 (Xenial Xerus) by recovering the filesystem as follows:

  1. Boot from a USB stick (try Ubuntu without installing)

  2. Find the boot drive (check the drive capacity or do the fsck on each partition):

    sudo fdisk -l
    
  3. Recover the file system:

    sudo fsck /dev/sdb1
    
  4. After the file system is fixed and clean, reboot the machine from the boot drive.

You must log in to answer this question.

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