My config: opensuse 11.4, boot partition at pendrive and hard drives with partitions sda1, sda2, sdb1.

Today I changed chassis for my computer, and by mistake I attached second drive to SATA 3 instead of SATA 2. So second drive was not mounted correctly. I turned off computer, attached it correctly and then my problem started.

Now, I cannot boot system at all. Previously I set booting from removable drive in BIOS (pendrive), but now it seems computer (BIOS) does not recognize pendrive as removable drive, but regular HDD. So it won't boot for "removable drive". When I change boot order, and select to boot from hard drive (and I set first hard drive as pendrive) or if I directly set from boot menu to boot from pendrive I get error in GRUB which goes into rescue mode.

My guess is, since because of some reason, pendrive is no longer recognized as removable media, but hard disk, hard drives are mapped differently and I should fix the mappings.

I can boot CD installer and mount pendrive to see the content of grub config, but when I am in grub rescue mode and I execute "ls" I get

(hd0) (hd0,msddos1) (hd1) (hd1,msddos2) (hd1,msdos1) (hd2) (hd2,msddos1)

But I don't see the mapping, so I don't know what hd0 really means. I can only suspect hd1 here is sda, because it has 2 partitions (if suffix msdsos is indication of partitions).

How can I make grub work again?

3 Answers 3


The problem is probably with grub seeing usb disks at boot time differently than once run from a running system. Here's how you might solve it:

When you boot (normally, from the hd) and grub appears, open grub console (usually you do that just by pressing c). At grub prompt, start typing root (hd :

grub> root (hd

then press Tab and you'll see the disks as possible completions. Choose the disk and partition where your /boot is. If you are not sure, then with each one you suspect, do the following:

  • (finish the root command to choose the partition and press Enter)
  • type in cat / and press Tab. You will see the list of files found on the partition.
  • Seeing the list of files, decide if it is your partition containing the kernel (under /boot/).
  • If not, press Esc and start over.

Once you've found how the partition is known to grub, you can re-install the boot loader (using setup command) and point to the correct partition/files in your /boot/grub/menu.lst or /boot/grub/grub.conf (you must determine, which of those your version uses, or just make them contain the same).

[Edit]: Per special request form Macias, here are more details on how to fix the MBR using grub:

One way to re-install the MBR on a drive using grub is the setup command I referred to above. This is a command known to grub versions 0.9X (see the Documentation). But you seem to be using the newer branch of grub (1.9X) and the commands for it are different. Have a look at the corresponding documentation - in this version, you can install grub to the MBR using the grub-install utility and I am not sure if there is any other way - from the grub "rescue" prompt, as with grub-0.97. Maybe not and maybe that is one of the reasons why many distros prefer the "legacy" version.

  • Thank you for the answer but this is theoretical solution, i.e. "When you boot (normally, from the hd) ". I don't boot from HDD, I boot from pendrive, there is no grub on HDD. Command "root" does not work with my grub or with grub in rescue mode, anyway, when I try to execute it, I get "unknown command". Aug 7, 2011 at 8:02
  • Ok, I didn't catch it that you had grub installed on usb, but it changes nothing. What does change something is the version of grub you have. Also, your question has become incomprehensible with all the edits - please, read it yourself and clean up, leaving the description of just what is the current problem. Aug 7, 2011 at 12:52
  • It is Grub1 for sure, I close this question for now, because now the problem shifted somewhere else and probably only me can fully solve this issue from the start. Aug 7, 2011 at 13:17
  • Well, maybe it's a good idea - you can then just start a new question when the situation gets clearer. From my answer, just keep in mind the fact that grub can be enumerating usb disks differently at boot time then when started from a running system. Hope this helps! Aug 7, 2011 at 13:22
  • I already posted question about last step of solution (my solution, it will be complex) unix.stackexchange.com/questions/18237/… I already noticed that grub is enumerating partitions differently, what's strange the partitions numbers vary between pendrives too, I have (hd0,1) on original pendrive and (hd0,0) on replacement pendrive. Aug 7, 2011 at 13:33

The file menu.lst is only used by grub-legacy. You appear to be using grub2, which uses grub.cfg instead. Grub2 also prefers to work without a device.map, so you might delete that as well, and then re-install grub.

  • Thank you for the answer, I don't have grub.cfg and I doubt it is Grub2 (how did you tell that?). Re-installing grub requires running system, right? I cannot run system, because grub is not working, if I could make it work, then (by definition) there would be no need for reinstalling it (because it would work). Aug 7, 2011 at 8:05
  • @macias it looks like grub2 because grub legacy enumerates partitions starting at zero, so the first partition it identifies as (hd0,0). Reinstalling grub requires a running system, which you can get by booting from something other than the HD with the broken grub.
    – psusi
    Aug 7, 2011 at 18:57

The solution to this problem is twofold. The one thing is fixing grub the other is fixing MBR.

The first one is pretty simple (?). Run your computer with install CD (openSUSE!), choose "rescue mode", once you get rescue mode running log in as root (no password is required), plug in pendrive, mount it (as for example ~/pendrive), go to ~/pendrive/grub and edit two files: device.map and menu.lst. In both files you have to look for entries (hdX) where X is (usually) 0 and 1. In my case I simply had to swap all 0 to 1, and all 1 to 0.

I don't know how to fix MBR easy way, but I hope Rozcietrzewiacz will come up with solution :-), just in case, the hard way is to grab another pendrive, and another hard disk, unplug all regular hard drives and perform "fake" installation which mimics the original one. If everything worked fine, and your new "fake" system booted up, it is time to copy MBR sectors from working pendrive to non-working (see: How to completely rebuild boot partition with grub as well?). You do it as explained below:

"Here, I'm assuming /dev/sdb is your OLD pendrive and /dev/sdc is the NEW one - make sure to replace those with appropriate device names, otherwise you can even mess up your entire system!

dd if=/dev/sdc bs=512 count=1 of=/dev/sdb

" (solution by Rozcietrzewiacz)

Those two steps is all you need to have your grub working again after disk reassignment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.