Skip to contentSkip to conversation

root seems to be incorrectly set after install

DISCUSSION George Lengel 4 participants 14 messages Feb 2, 2008 – Feb 9, 2008

lore
Share & tools
lore
#0 lore raw

Hello,

I have a problem with my grub2 installation. I am using the latest Debian package (1.95+20080128-1)and I could properly boot using the chainloader method suggested during the initial installation (grub-legacy still in MBR and it calls grub2), but when I decided to place grub2 in the MBR, it will not work.

I have a bit of a complicated disk setup. My hd0 is the BIOS boot disk, but /boot/grub resides on (hd2,7). I also have partitions spread all around my three drives with various OSs that I have not cleaned up (OS/2, DRDOS). I try to put grub2 in the MBR using grub-install (hd0) and then also try grub-setup directly and the setup almost works.

When I reboot I get thrown into rescue mode and typing set shows grub>prefix= (hd0,7)/boot/grub
grub>root=hd0,7

If I manually set root to (hd2,7) and prefix to (hd2,7)/boot/grub I can insmod normal and then running normal proceeds perfectly. It makes no sense to me why it is prepending hd0 instead of hd2. I have searched all over for a solution and the closest I came was someone a few months ago posted a similar problem. It was suggested to delete system.map and regenerate it, but this did not help.

Here is my device.map which makes sense to me

(fd0)    /dev/fd0
(hd0)    /dev/sda
(hd1)    /dev/sdb
(hd2)    /dev/sdc

and here is the output of grub-setup when I manually run it trying to get the proper file in the MBR. It clearly understands the root should be hd(2,7), but when it boots it seems to change it to hd(0,7).

ta-koro:/boot/grub# grub-setup --verbose  '(hd0)'
grub-setup: info: prefix = /boot/grub
grub-setup: info: changing current directory to /dev/mapper
grub-setup: info: changing current directory to /dev
grub-setup: info: changing current directory to mapper
grub-setup: info: changing current directory to bus
grub-setup: info: changing current directory to usb
grub-setup: info: changing current directory to 001
grub-setup: info: changing current directory to 002
grub-setup: info: changing current directory to snd
grub-setup: info: /dev/sdc7 starts from 5156928
grub-setup: info: opening the device hd2
grub-setup: info: the size of hd2 is 35566480
grub-setup: info: opening the device `/dev/sdc'
grub-setup: info: DOS partition 1 starts from 18040995
grub-setup: info: DOS partition 2 starts from 26619705
grub-setup: info: opening the device `/dev/sdc'
grub-setup: info: DOS partition 4 starts from 126
grub-setup: info: opening the device `/dev/sdc'
grub-setup: info: DOS partition 5 starts from 1783278
grub-setup: info: opening the device `/dev/sdc'
grub-setup: info: DOS partition 6 starts from 5156928
grub-setup: info: getting the size of /boot/grub/boot.img
grub-setup: info: reading /boot/grub/boot.img
grub-setup: info: getting the size of /boot/grub/boot.img
grub-setup: info: getting the size of /boot/grub/core.img
grub-setup: info: reading /boot/grub/core.img
grub-setup: info: getting the size of /boot/grub/core.img
grub-setup: info: the size of hd2 is 35566480
grub-setup: info: the size of hd0 is 17836668
grub-setup: info: setting the root device to `hd2,7'
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: will embed the core image into after the MBR
grub-setup: info: dos partition is 6, bsd partition is -1, prefix is /boot/grub
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: opening the device `/dev/sda'

Does anybody have an idea what is wrong here? I would appreciate any advice and help.

#1 lore raw
Quoted 10 lines · George Lengel

When I reboot I get thrown into rescue mode and typing set shows grub>prefix= (hd0,7)/boot/grub
grub>root=hd0,7

If I manually set root to (hd2,7) and prefix to (hd2,7)/boot/grub I can insmod normal and then running normal proceeds perfectly. It makes no sense to me why it is prepending hd0 instead of hd2. I have searched all over for a solution and the closest I came was someone a few months ago posted a similar problem. It was suggested to delete system.map and regenerate it, but this did not help.

Sounds like grub_boot_drive not having the right info. It works when received via multiboot, but not from boot.img.

Does the attached patch fix your problem? Just a guess ...

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
boot/i386/pc/boot.S +0 -15
diff -ur grub2/boot/i386/pc/boot.S tmp/boot/i386/pc/boot.S
@@ -105,21 +105,6 @@
 /* general setup */
 	cli		/* we're not safe here! */
 
-        /*
-         * This is a workaround for buggy BIOSes which don't pass boot
-         * drive correctly. If GRUB is installed into a HDD, check if
-         * DL is masked correctly. If not, assume that the BIOS passed
-         * a bogus value and set DL to 0x80, since this is the only
-         * possible boot drive. If GRUB is installed into a floppy,
-         * this does nothing (only jump).
-         */
-boot_drive_check:
-        jmp     1f	/* grub-setup may overwrite this jump */
-        testb   $0x80, %dl
-        jnz     1f
-        movb    $0x80, %dl
-1:
-	
 	/*
 	 * ljmp to the next instruction because some bogus BIOSes
 	 * jump to 07C0:0000 instead of 0000:7C00.
util/i386/pc/grub-setup.c +0 -7
diff -ur grub2/util/i386/pc/grub-setup.c tmp/util/i386/pc/grub-setup.c
@@ -246,13 +246,6 @@
 
   free (tmp_img);
   
-  /* If DEST_DRIVE is a hard disk, enable the workaround, which is
-     for buggy BIOSes which don't pass boot drive correctly. Instead,
-     they pass 0x00 or 0x01 even when booted from 0x80.  */
-  if (dest_dev->disk->id & 0x80)
-    /* Replace the jmp (2 bytes) with double nop's.  */
-    *boot_drive_check = 0x9090;
-  
   /* If the destination device can have partitions and it is the MBR,
      try to embed the core image into after the MBR.  */
   if (dest_dev->disk->has_partitions && ! dest_dev->disk->partition)
#2 lore raw
Quoted 7 lines · Robert Millan

Sounds like grub_boot_drive not having the right info. It works when received via multiboot, but not from boot.img.

Does the attached patch fix your problem? Just a guess ...

Hello,

Thanks for the try. It did not appear to make a difference, though I cannot rule out I did not apply the patch and recompile correctly. I hope I did though and everything I checked indicated I was using my compiled version and not the original Debian package. Is there something I can check so we can be convinced I am using the patched version?

What you said in the comments of the patch actually makes sense. I remember many years ago I had an odd issue with OS/2 Boot Manager acting strange. Eventually, the culprit seemed to be something buggy with my BIOS and the way it booted drives. It has been a long time and I don't remember the specific details, but I am sure there was something similar to your idea.

#3 lore raw
Quoted 10 lines · George Lengel
Quoted 8 lines · Robert Millan

Sounds like grub_boot_drive not having the right info. It works when received
via multiboot, but not from boot.img.

Does the attached patch fix your problem? Just a guess ...

Quoted 6 lines

Hello,

Thanks for the try. It did not appear to make a difference, though I cannot rule out I did not apply the patch and recompile correctly. I hope I did though and everything I checked indicated I was using my compiled version and not the original Debian package.

You need to be sure. It's hard enough to try guessing what the problem may be, to make it even harder this way.

Quoted 2 lines

Is there something
I can check so we can be convinced I am using the patched version?

Try:

kern/i386/pc/init.c 2008-02-03 11:58:31.000000000 +0100 renamed from kern/i386/pc/init.c 2008-01-23 12:25:52.000000000 +0100 +2 -0
diff -ur grub2/kern/i386/pc/init.c tmp/kern/i386/pc/init.c
@@ -232,6 +232,8 @@
 
   if (! grub_os_area_addr)
     grub_fatal ("no upper memory");
+
+  grub_printf ("%p\n", grub_boot_drive);
 }
 
 void

this will also tell you the grub_boot_drive value (let us know).

Quoted 6 lines

What you said in the comments of the patch actually makes sense. I remember many years ago I had an odd issue with OS/2 Boot Manager acting strange. Eventually, the culprit seemed to be something buggy with my BIOS and the way it booted drives. It has been a long time and I don't remember the specific details, but I am sure there was something similar to your idea.

What version of GRUB Legacy did you install in that system? Did you modify GRUB Legacy when you installed it, or something like that?

Does a recent GRUB Legacy install work on that board?

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
#4 lore raw
Quoted 37 lines · Robert Millan
Quoted 5 lines · George Lengel
Quoted 3 lines · Robert Millan

Sounds like grub_boot_drive not having the right info. It works when received via multiboot, but not from boot.img.

Quoted 7 lines
Quoted 3 lines

Does the attached patch fix your problem? Just a guess ...

Hello,

Thanks for the try. It did not appear to make a difference, though I cannot rule out I did not apply the patch and recompile correctly. I hope I did though and everything I checked indicated I was using my compiled version and not the original Debian package.

You need to be sure. It's hard enough to try guessing what the problem may be, to make it even harder this way.

Quoted 2 lines

Is there something I can check so we can be convinced I am using the patched version?

Try:

diff -ur grub2/kern/i386/pc/init.c tmp/kern/i386/pc/init.c

kern/i386/pc/init.c 2008-02-03 11:58:31.000000000 +0100 renamed from kern/i386/pc/init.c 2008-01-23 12:25:52.000000000 +0100 +2 -0
@@ -232,6 +232,8 @@
 
   if (! grub_os_area_addr)
     grub_fatal ("no upper memory");
+
+  grub_printf ("%p\n", grub_boot_drive);
 }
 
 void
Quoted 2 lines

this will also tell you the grub_boot_drive value (let us know).

Dear Robert,

I now get a 0x80 at the top of the screen just before the rescue mode line. This indicates I am using my compiled version and also confirms your suspicion about the BIOS, right?

Quoted 4 lines

What version of GRUB Legacy did you install in that system? Did you modify GRUB Legacy when you installed it, or something like that?

I use Grub legacy from Debian which is 0.97. It has worked for years and years without any problem and I never did anything past a simple apt-get and accept the defaults when configuring it.

#5 lore raw
Quoted 8 lines · George Lengel

Dear Robert,

I now get a 0x80 at the top of the screen just before the rescue mode line. This indicates I am using my compiled version and also confirms your suspicion about the BIOS, right?

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

What version of GRUB Legacy did you install in that system? Did you modify GRUB Legacy when you installed it, or something like that?

I use Grub legacy from Debian which is 0.97. It has worked for years and years without any problem and I never did anything past a simple apt-get and accept the defaults when configuring it.

Can you check if you can override the root device by invoking grub-setup manually with --root-device parameter?

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
#6 lore raw
Quoted 10 lines · Robert Millan
Quoted 9 lines · George Lengel

Dear Robert,

I now get a 0x80 at the top of the screen just before the rescue mode line. This indicates I am using my compiled version and also confirms your suspicion about the BIOS, right?

Quoted 2 lines

What version of GRUB Legacy did you install in that system? Did you modify GRUB Legacy when you installed it, or something like that?

Quoted 6 lines
Quoted 3 lines

I use Grub legacy from Debian which is 0.97. It has worked for years and years without any problem and I never did anything past a simple apt-get and accept the defaults when configuring it.

Can you check if you can override the root device by invoking grub-setup manually with --root-device parameter?

I have looked at this problem deeply, and I think the following changes would be required:

- A variable to specify where grub.cfg and modules are present. Currently, we have it only for a prefix without a drive. So grub_root_drive or something must be added. It could be added to kern/i386/pc/startup.S, but boot/i386/pc/boot.S might be more appropriate (if there is space large enough).

- grub-setup must handle a root drive independently, of a boot drive or an embedding drive.

- kern/i386/pc/init.c must be modified accordingly.

The scinarii would be the following:

- If a core image is embedded, and a grub directory is in the same drive, all drives should be set to -1, thus a boot drive passed by BIOS or another boot loader will be used.

- If a core image is embedded, and a grub directory is in a different drive, a root drive must be explicitly set by grub-setup. The other drives will be set by BIOS or another boot loader.

- If a core image is not embedded, and it is in the same drive, the same as the first example.

- If a core image is not embedded, and it is in a different drive, an embedding drive is identical to a root drive, and must be set explicitly by grub-setup.

I am planning to fix it myself, but if I look too slow, please feel free to fix it instead of me.

Okuji

#7 lore raw
Quoted 45 lines · Yoshinori K. Okuji
Quoted 10 lines · Robert Millan
Quoted 9 lines · George Lengel

Dear Robert,

I now get a 0x80 at the top of the screen just before the rescue mode line. This indicates I am using my compiled version and also confirms your suspicion about the BIOS, right?

Quoted 2 lines

What version of GRUB Legacy did you install in that system? Did you modify GRUB Legacy when you installed it, or something like that?

Quoted 6 lines
Quoted 3 lines

I use Grub legacy from Debian which is 0.97. It has worked for years and years without any problem and I never did anything past a simple apt-get and accept the defaults when configuring it.

Can you check if you can override the root device by invoking grub-setup manually with --root-device parameter?

I have looked at this problem deeply, and I think the following changes would be required:

- A variable to specify where grub.cfg and modules are present. Currently, we have it only for a prefix without a drive. So grub_root_drive or something must be added. It could be added to kern/i386/pc/startup.S, but boot/i386/pc/boot.S might be more appropriate (if there is space large enough).

- grub-setup must handle a root drive independently, of a boot drive or an embedding drive.

- kern/i386/pc/init.c must be modified accordingly.

The scinarii would be the following:

- If a core image is embedded, and a grub directory is in the same drive, all drives should be set to -1, thus a boot drive passed by BIOS or another boot loader will be used.

- If a core image is embedded, and a grub directory is in a different drive, a root drive must be explicitly set by grub-setup. The other drives will be set by BIOS or another boot loader.

- If a core image is not embedded, and it is in the same drive, the same as the first example.

Quoted 6 lines

- If a core image is not embedded, and it is in a different drive, an embedding drive is identical to a root drive, and must be set explicitly by grub-setup.

I am planning to fix it myself, but if I look too slow, please feel free to fix it instead of me.

I think I have fixed it. Please test it, if you can.

Okuji

#8 lore raw

Re: root seems to be incorrectly set after install (patch works)

Quoted 32 lines
Quoted 32 lines

I have looked at this problem deeply, and I think the following changes would be required:

- A variable to specify where grub.cfg and modules are present. Currently, we have it only for a prefix without a drive. So grub_root_drive or something must be added. It could be added to kern/i386/pc/startup.S, but boot/i386/pc/boot.S might be more appropriate (if there is space large enough).

- grub-setup must handle a root drive independently, of a boot drive or an embedding drive.

- kern/i386/pc/init.c must be modified accordingly.

The scinarii would be the following:

- If a core image is embedded, and a grub directory is in the same drive, all drives should be set to -1, thus a boot drive passed by BIOS or another boot loader will be used.

- If a core image is embedded, and a grub directory is in a different drive, a root drive must be explicitly set by grub-setup. The other drives will be set by BIOS or another boot loader.

- If a core image is not embedded, and it is in the same drive, the same as the first example.

- If a core image is not embedded, and it is in a different drive, an embedding drive is identical to a root drive, and must be set explicitly by grub-setup.

Quoted 6 lines
Quoted 3 lines

I am planning to fix it myself, but if I look too slow, please feel free to fix it instead of me.

I think I have fixed it. Please test it, if you can.

Hello,

I pulled the latest source from CVS tonight and after compiling and installing, it looks like your patch works! I no longer was dropped into rescue mode and my system booted.

I did encounter one problem. My screen is corrupted and the menu is unreadable. Grub is loading the menu correctly and if I wait for the timeout, everything boots fine. This is not a problem unless at some point I need to read the screen. :)

#9 lore raw

screen corruption

Quoted 5 lines · George Lengel

I did encounter one problem. My screen is corrupted and the menu is unreadable. Grub is loading the menu correctly and if I wait for the timeout, everything boots fine. This is not a problem unless at some point I need to read the screen. :)

Can you take a picture of that?

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
#10 lore raw

Re: screen corruption

Quoted 8 lines · Robert Millan
Quoted 2 lines · George Lengel

I did encounter one problem. My screen is corrupted and the menu is unreadable. Grub is loading the menu correctly and if I wait for the timeout, everything boots fine. This is not a problem unless at some point I need to read the screen. :)

Can you take a picture of that?

I hope you can tell what is going on even though the picture is a bit out of focus. Each character is a fuzzy gray box instead of a letter.

#11 lore raw

Re: screen corruption

Quoted 10 lines · George Lengel
Quoted 8 lines · Robert Millan
Quoted 2 lines · George Lengel

I did encounter one problem. My screen is corrupted and the menu is unreadable. Grub is loading the menu correctly and if I wait for the timeout, everything boots fine. This is not a problem unless at some point I need to read the screen. :)

Can you take a picture of that?

I hope you can tell what is going on even though the picture is a bit out of focus. Each character is a fuzzy gray box instead of a letter.

missing fonts?

#12 lore raw

Re: screen corruption

Quoted 4 lines
Quoted 2 lines

I hope you can tell what is going on even though the picture is a bit out of focus. Each character is a fuzzy gray box instead of a letter.

missing fonts?

Hi,

Thanks for the hint. This was the problem. From what I can tell when I switched from the Debian package to compiling it on my own from CVS, removing the Debian package removed the font and I had not realized this.

Everything looks perfect now.

You guys are a great group of developers. My original problem with the wrong boot drive passed was fixed very quickly and now my silly font problem was also diagnosed right away.

#13 lore raw

Re: screen corruption

In reply to George Lengel
Quoted 9 lines · George Lengel
Quoted 8 lines · Robert Millan
Quoted 5 lines · George Lengel

I did encounter one problem. My screen is corrupted and the menu is unreadable. Grub is loading the menu correctly and if I wait for the timeout, everything boots fine. This is not a problem unless at some point I need to read the screen. :)

Quoted 5 lines
Quoted 3 lines

Can you take a picture of that?

I hope you can tell what is going on even though the picture is a bit out of focus. Each character is a fuzzy gray box instead of a letter.

What's in your grub.cfg ?

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)