Announcement

Collapse
No announcement yet.

grub2 writes to boot sector of all attached drives?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    grub2 writes to boot sector of all attached drives?

    I have a dual boot, running 9.04 on one drive, SATA, and then I installed 9.10 on an IDE drive.

    The SATA drive is assigned sda by both, and is recognized as such.
    the IDE drive is sdb, and also recognized by both 9.04 and 9.10 as this device identifier.

    I installed Karmic to the IDE drive with the SATA drive removed, and everything went fine. The grub2 menu did not get populated with anything other than Karmic, and that is ok. I usually change the boot device from the BIOS menu when testing new releases anyway.

    However, a couple weeks ago, I was playing with Grub2, trying to figure out how it works [still sadly confused] and did the update-grub command while both drives were installed. I had booted off of the IDE drive with 9.10 installed, and was trying to see if I could get changes made to the grub.cfg file and also see if the 9.04 entries would carry over.

    I did get the options in grub2 changed - took out quiet and splash - but the 9.04 entries didn't appear.

    I'm really not sure what the difference between the update-grub and the update-grub2 commands are, or if there really is any, but what I discovered is that when I did the update-grub command, it wiped the grub on the SATA drive, making the SATA drive unbootable.

    I'm guessing that it added some grub2 bits to sda - even though sdb was the controlling drive, and after this alteration, the SATA drive wanted to a grub2 boot when it was the only drive, and had a mix of grub and grub2 stuff, making it unbootable.

    It would get to the booting grub line, and then grub would report:

    error - no such disk
    grub rescue>

    I got some of the commands to be recognized in the rescue prompt, but that didn't really help me get it to boot.

    What did fix this problem was to boot into a grub 1 system and then set up grub1 again on the SATA drive. the menu.lst file was not altered, so as soon as grub1 was correctly set up, it booted fine again.

    Not sure if this is a bug or just something that got weird for me.

    There is another bug report, but I'm not sure if it is the same type of problem - it is filed with mythbuntu.

    https://bugs.launchpad.net/ubuntu/+s...b2/+bug/414996

    I really don't want to try running the update-grub command again [maybe the update-grub2 would work?] but I would like to see if I can get entries from both drives if I do move to Karmic when it is released.

    Any ideas?

    thanks

    #2
    Re: grub2 writes to boot sector of all attached drives?

    Here:

    The installation program is starting the hard drive count from the SATA drives.

    I have 2x PATA (ide) and 2x SATA. Old way with the Legacy Grub was to count the PATA drives before the SATA drives. If i want to use the Grub2 i need to go to the bios settings and change the "First Boot Device" from the "HDD-0" to the "SCSI".


    Links:

    > Topic: GRUB 2: A Guide for Users
    > Revert from grub2 to legacy grub - not a tutorial!
    Before you edit, BACKUP !

    Why there are dead links ?
    1. Thread: Please explain how to access old kubuntu forum posts
    2. Thread: Lost Information

    Comment


      #3
      Re: grub2 writes to boot sector of all attached drives?

      Just some thoughts ...

      > Might have been better to leave BOTH drives in while installing Karmic (it certainly appears that doing so would not have been any worse).

      > May be some bugginess with GRUB 2 and the dual booting, I don't know quite yet, will be experimenting soon to see for myself, but I see "issues" like yours popping up now and then in the forums.

      > I have also noticed some quirky behavior when the old GRUB Legacy is mixed with the GRUB 2, with remnants of GRUB legacy seeming to confuse things. On the other hand, when you are in trouble, using Super Grub Disk live CD to restore GRUB Legacy to the controlling (first BIOS drive) can be a life saver! (And then, of course, you gotta boot into your OS (using the GRUB Legacy) and proceed to fix things, perhaps even re-installing GRUB 2 or whatever you wish to do at that point.)

      > For Karmic, instead of update-grub, maybe try
      grub-mkconfig

      > To include an OS that has been omitted from your controlling grub.cfg, make a custom boot entry for it (see the linked how-to) by creating a script in /etc/grub.d, then run update-grub or grub-mkconfig.

      > In any case, and whatever you've done, and whatever is the current problem, you can always try to re-install grub using sudo grub-install either from the controlling OS or from a live Kubuntu CD (again, see my how-to).

      -- GRUB 2 A Guide for Users
      http://kubuntuforums.net/forums/inde....msg195860#new


      An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

      Comment


        #4
        Re: grub2 writes to boot sector of all attached drives?

        Too bad the install does not give you the option of installing Grub Legacy. I installed Karmic, and as usual, started playing around with things, and screwed up the Grub2 somehow. Now when I do this, I usually just boot into another distro and fix it by mounting the file system and correcting things. But in this case I installed Karmic using ext4 and it won't mount in Hardy. So I had to use the live CD and reinstall Grub2.

        Comment


          #5
          Re: grub2 writes to boot sector of all attached drives?

          At the beginning, choose F6, for further options and expert mode gives you lots more options, including the choice between GRUB and GRUB2 with the warning that GRUB2 is still experimental and should not be used for production systems.

          I had problems getting GRUB to install either on MBR or another partition when I installed with encrypted /home and swap. (/ was ext3 not encrypted). Does GRUB2 require ext4?

          I had problems with earlier versions (alpha 3) and GRUB2 when I had /boot on its own partition, so stopped mounting /boot on its own partition.

          Most problems with GRUB or GRUB2 can be solved by booting from any Kubuntu CD and choosing repair a broken system instead of install.
          HP Compaq nc6400, 2Gi, 100Gi, ATI x1300 with 512M

          Comment


            #6
            Re: grub2 writes to boot sector of all attached drives?

            "Does GRUB2 require ext4?"

            No.
            An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

            Comment


              #7
              Re: grub2 writes to boot sector of all attached drives?

              Is it that Grub2 and Grub don't play well together, or that installing Grub2 using ext4 on a multi-boot (linux) system where the other linux OS's use Grub (ext3) the problem? Either way, why didn't the devs take this into consideration when creating the installer for Karmic? Seems to me, that they would just have had to do a systems check to determine which boot loader was already present. If it was a linux OS using Legacy Grub with ext3, then issue a warning about using ext4 for the root or /boot mount point, or exclude the use of ext4 on the root or /boot mount point to ensure compatibility.
              Windows no longer obstructs my view.
              Using Kubuntu Linux since March 23, 2007.
              "It is a capital mistake to theorize before one has data." - Sherlock Holmes

              Comment


                #8
                Re: grub2 writes to boot sector of all attached drives?

                Originally posted by kevinc
                At the beginning, choose F6, for further options and expert mode gives you lots more options, including the choice between GRUB and GRUB2 with the warning that GRUB2 is still experimental and should not be used for production systems.
                That's good to know. Thanks.

                Comment


                  #9
                  Re: grub2 writes to boot sector of all attached drives?

                  Now I know there are mysterious forces are work in grub 2.

                  I haven't done any manual reconfiguring of grub 2 for my Karmic drive, but today - in dealing with an internet issue - I tried to boot into 9.04 again, and the grub 1 install on that drive was toasted again.

                  The only thing I have done since restoring grub 1 last time was to do a system update in Karmic - including getting new kernel versions.

                  As I watched synaptic run through all the steps, I did happen to see grub 2 updating - obviously to add the menu items for the new kernel.

                  What I really wasn't expecting was that it would toast the grub 1 files or the mbr of the non-active drive again.

                  So, it does seem to me that grub 2 will set itself up on either the sda drive [which my 9.04 grub 1 install resides on, but I boot into sdb for Karmic] or do all the drives. I don't really want to add a 3rd drive to test this part.

                  I don't know what the default grub 2 options are - such as "always write to booted system drive, and sda" or "write grub 2 to all drives just in case they want to boot", but that doesn't really seem like it would be a good thing for any boot loader to do.

                  I guess I am always scared whenever I install a new distro, so I install it with only a single hard drive in the system - making the install grub recognize the drive as sda or hd0, [whatever it likes to think as]. Only after the initial install is complete do I add the other drive, so that as little as possible can go wrong on the second drive.

                  Maybe because of this, grub 2 is acting weird for me.

                  No idea what the fix is, but from here on out, any kernel updates will be done with a single drive installed to protect the other grub installs.

                  I would really like to hear from someone who has more than 2 drives that boot - have you noticed that grub 2 has propagated to those as well?

                  thanks

                  Comment


                    #10
                    Re: grub2 writes to boot sector of all attached drives?

                    I don't have more than two drives so I can't comment on GRUB2 writing to all or more than one drive,
                    however I can offer a simple workaround if you want to run Jaunty and Karmic. Simply use Jaunty to write your MBR and use Karmic to write to another partition such as the / partition on which Karmic resides.

                    There was an update of a bug report # 392836 this morning confirming that GRUB2 in Karmic does not write the correct UUID to grub.cfg

                    Probably this will be fixed within a few days.
                    HP Compaq nc6400, 2Gi, 100Gi, ATI x1300 with 512M

                    Comment


                      #11
                      Re: grub2 writes to boot sector of all attached drives?

                      I have only tested GRUB 2 on one drive (dual booting). Too many buggy reports concerning two drives thus far, along with the UUID issue kevinc cited. However, I can almost certainly guarantee that GRUB 2 was not written to install itself in multiple locations. The devs would have to be drunk to do that. Usually, the default would be to install GRUB 2 to the drive that is detected as hd0 = the current BIOS boot drive. If you install by live CD method, you could make sure where GRUB 2 will go by using Manual partitioning and in the Summary step clicking the Advanced button at lower right (see Appendix to the GRUB 2 Guide: GRUB 2 A Guide for Users
                      http://kubuntuforums.net/forums/inde...opic=3106368.0 )

                      The workaround kevinc suggested will work--you can always boot one GRUB from another GRUB by chainloading (assuming the chainloaded GRUB is installed to the partition boot sector; or to the MBR if the whole drive is being chainloaded from another drive).

                      You can clear out a MBR using dd, then do something, then print that same MBR (in hex) to screen using dd to see if something was installed to the MBR (explained in my GPT experiment, Reply #1 to the GRUB 2 Guide). I've done that to test GPT, kind of exploring like you are doing here, trying to chase down GRUB.
                      An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

                      Comment


                        #12
                        Re: grub2 writes to boot sector of all attached drives?

                        thanks Qqmike, that's pretty good advice.

                        If I manage to get the courage to try reading the mbr and noting the changes, I will post them.

                        This seems to be grub2 specific for me, because pretty much I do the same thing for every new version that I test - install on a single drive, then add the other drive after the install.

                        I have no idea if grub1 exhibits this same problem because previously all of my boot loaders were grub1, which wouldn't have really changed if grub were changed on all of the drives. Now with grub 2, these changes would be very evident.

                        Comment


                          #13
                          Re: grub2 writes to boot sector of all attached drives?

                          Well, I've forgotten what I knew about actually reading the MBR. You learn that stuff from the man -- Starman (google him). But I know when GRUB is there, toward the end of the 512 bytes, you see things like G R U B, and geometry error, and other familiar stuff, ending with the usual boot record EOF 0xaa55 (in two bytes: aa and 55).

                          So I keep this real simple.

                          Clear (write zeros to) the MBR; say it is drive sdc:

                          sudo dd if=/dev/zero of=/dev/sdc bs=512 count=1

                          Check it:
                          sudo dd if=/dev/sdc bs=512 count=1 | hexdump -C

                          (all zeros?; ***** = large blocks of zeros)

                          Then do the experiment involving GRUB.

                          Then print the MBR to the screen again:
                          sudo dd if=/dev/sdc bs=512 count=1 | hexdump -C

                          (actually, block size in bytes bs=512 is the default, but it's nice to type it and see it)

                          => You can see if GRUB got installed in the MBR (or, if it seems so, with high probability).
                          An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

                          Comment


                            #14
                            Re: grub2 writes to boot sector of all attached drives?

                            It's been a while, but the problem returned.

                            I did several updates in the meantime, with all of them creating no grub problems until this last one.

                            I think the problem is in identifying hd0. When I have both of my drive connected, the SATA drive always comes up as sda, making it hd0. for some reason it seems that grub2 wants to write itself to hd0 - but for me that isn't the current boot drive.

                            Here is where I think grub2 was written to sda:

                            Setting up grub-common (1.97~beta4-1ubuntu3) ...

                            Setting up grub-pc (1.97~beta4-1ubuntu3) ...
                            Installation finished. No error reported.
                            This is the contents of the device map /boot/grub/device.map.
                            Check if this is correct or not. If any of the lines is incorrect,
                            fix it and re-run the script `grub-install'.

                            (hd0) /dev/sda
                            (hd1) /dev/sdb
                            (hd2) /dev/sdg
                            Generating grub.cfg ...
                            Found linux image: /boot/vmlinuz-2.6.31-14-generic
                            Found initrd image: /boot/initrd.img-2.6.31-14-generic
                            Found linux image: /boot/vmlinuz-2.6.31-13-generic
                            Found initrd image: /boot/initrd.img-2.6.31-13-generic
                            Found linux image: /boot/vmlinuz-2.6.31-12-generic
                            Found initrd image: /boot/initrd.img-2.6.31-12-generic
                            Found linux image: /boot/vmlinuz-2.6.31-11-generic
                            Found initrd image: /boot/initrd.img-2.6.31-11-generic
                            Found linux image: /boot/vmlinuz-2.6.31-10-generic
                            Found initrd image: /boot/initrd.img-2.6.31-10-generic
                            Found linux image: /boot/vmlinuz-2.6.31-9-generic
                            Found initrd image: /boot/initrd.img-2.6.31-9-generic
                            Found memtest86+ image: /boot/memtest86+.bin

                            and I copied the mbr from sda before and after to see where the differences were. these are attached.

                            As a summary, here is my configuration:

                            SATA drive, sda with kubuntu 9.04 with grub 1
                            IDE drive, sdb with kubuntu 9.10 and grub2
                            BIOS is set to boot from sdb first, booting into karmic.

                            When I boot into Karmic, and update grub2, it apparently writes the grub2 stuff to sda's mbr. I can still boot into karmic at the latest kernel versions, but now grub1 is corrupted and I have to fix it before I can boot into Jaunty with the real sda.

                            I'm not sure how common this type of configuration is, so maybe that is the bigger problem, however I don't really like having to fix grub to get back into Jaunty.

                            Also, the mbr of sdb hasn't changed with this latest update - so I don't know what level of grub2 I am actually running on the boot disk at the moment.

                            Attached Files

                            Comment


                              #15
                              Re: grub2 writes to boot sector of all attached drives?

                              "Also, the mbr of sdb hasn't changed with this latest update - so I don't know what level of grub2 I am actually running on the boot disk at the moment."

                              If you boot into 9.10 and issue
                              sudo grub-install -v
                              it should tell you your GRUB 2 version.


                              You've explained the problem very well, nice layout.

                              When a PC boots from a HD, during that booted session, THAT hard drive is always seen as hd0 by BIOS and by GRUB. In your case, sdb will always be seen as hd0, then comes your other HDs as hd1, etc. I would think that if you boot from sdb into 9.10, get the updates, that GRUB 2 should see sdb as hd0 and go from there, not touching the MBR of sda. But that isn't happening. Looks like a bug, doesn't it?

                              I'm not sure what good this will do but to satisfy some curiosity, but if you boot into 9.10, get Konsole, and explore your drives using ls, what would you see? Hopefully, of course, hd0 = sdb, etc.
                              in 9.10, try GRUB emulation shell:

                              in Konsole
                              sudo grub-emu
                              grub>ls

                              And, you might try it using the GRUB CLI upon rebooting:
                              reboot the PC (where sdb is set to be first in BIOS boot order)
                              see the boot menu and quickly hit the "c" key to get the GRUB prompt, grub>

                              grub>ls

                              you can also do things like
                              grub>ls (hd0,1)/
                              or
                              grub>ls (hd0,1)
                              and so on
                              (grub> help ls, or see my GRUB 2 how-to)
                              Hit ESC to get your boot menu back.

                              Puzzling.
                              An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

                              Comment

                              Working...
                              X