booting with grub: how to debug

I would like to build a sticky subject about repairing openSUSE boot.
This article, once complete (not by me alone) should be made sticky (to have it in front of the forum) - these problems are frequent and disturbing.
I know the great work done by please-try-again. But very often we don’t need any script (and running a script from rescue mode is very difficult) - that said I vote to have the pta scripts included in the rescue system !
So I would like to focus on command line fixes.
I will at first use a post for each issue

  • after installing Windows, your openSUSE install don’t boot, grub do not even show up and Windows starts immediately
  • when you boot, you_ get “no operating system”

These symptoms often are found afetr installing either Windows or an other Linux.

These comments are about grub legacy, aka grub 1. grub 2 is an other story. But according to the factory list users on may 2011, grub 1 is to be used by openSUSE probably including 12.1 (as default).

Classical partitions, the only ones to be still current can have up to 4 primary partitions (numbered 1, 2, 3, 4), one of them can be an extended partition and any number of logical partitions can be included in the extended one, numbering beginning at 5 (what ever number of primary partitions).
Any number of the partitions can have a “boot flag”, but only one should be kept.

The fisrt sector of the first disk is called a MBR or Master Boot Record. Practically, any disk can have one, but only the first one is valid.

The BIOS (Basic Input Output System) is the system included with the hardware and we can’t change it above what the maker allows.

Standard BIOS read and execute the first byte of the first hard drive. This reads and execute the MBR.

This is only a draft, the real situation is more complex, for example the MBR is only part of the first sector, an other part is the partition table.

The boot operation is the following: if the MBR is a grub MBR, this grub install takes hand and do what it wants. If it’s a “standard” MBR, the MBR code read the boot flag and send the execution to the fisrt sector of the flagged partition. Only a primary partition (including the extended one) can hold usefully a boot flag.

by default, openSUSE write a standard MBR and flag as bootable the root partition, the extended one if the root partition is a logical partition.
At the same time, grub is written in the flagged partition.

With this config, the boot flag is important to boot openSUSE

The openSUSE install is standard. An other install broke the boot.

Start any openSUSE dvd (not too old) in rescue mode. Do not forget to choose your langage pressing F2 on the starting screen.

use “fdisk -l” to see what are the disks partitions. The flagged one have an “*”.

You can mount on /mnt any partition to see it’s content.

once you have identified you root partition, use “fdisk /dev/your-drive” to change this. On fdisk, you have to type “p” to see the list of partitions, a to switch the flag (fdisk will ask the partition number). If your root is logical (number 5 or up), flag the extended one.


With some luck, you will find back your grub menu

the previous system don’t work. bad chance :-(.

You have to work out the grub config. For this you need to launch yast as root on your own install.

Launch the rescue system. Mount your root partition on /mnt.

after that do the following

cd /mnt
mount --bind /sys sys
mount --bind /proc proc
mount --bind /dev dev
chroot .

do not forget the dot at the end of the last line. Typing the mount lines is easy using the keyboard arrows, you have to type “mount --bind /sys sys, up arrow, back key to replace sys by proc…”

at this moment, you are root. You can launch yast and edit the boot loader.

You can boot openSUSE, but 11.4 do not create a Windows entry, so you can’t boot your Windows.

You have to figure out how grub manage your disk. Windows partition is probably the first one (up to vista) or the first and the second one (W7).

So boot. When you see the boot screen, hit “Esc” ->grub ask you if you want the text mode boot screen yes, you want it!. Then you will have to use the grub minineditor. Frightening - you are probably with the ascii us keyboard :-(, but not that difficult. Remember, the TAB completion works awfully well.
so on the text menu, type “c” to get the command line.
type “root (hd [TAB]” (hit the TAB key after typing hd). grub shows what you can have after or complete itself if there is only one choice. continue typing. After you give the disk name (remember, grub counts from 0, not from 1, so sda1 is hd0,0).
After the disk name is complete, type “/” and TAB. grub will mount the partition and show you the root content if it’s a linux partition. If not, it will complaint hat it can’t mount this (probably NTFS) partition.
Type enter. Grub will complain, but take it as root anyway.
Type “chainloader +1” then “boot”
If Windows boots, you have your result. If not, do again with an other partition number. The partition should be 0 or 1 (except if you installed windows yourself elsewhere).

Once you have found the windows boot partition, go to openSUSE, use vi or kwrite as root and edit the /boot/grub/menu.lst file, adding at the end:

title windows
rootnoverify (hdX,Y) of course the found value, noverify prevent error messages
chainloader +1

that’s all folks.