Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 24

Thread: [SOLVED] How to determine which Linux partition w/ Grub controls the MBR?

  1. #11
    Join Date
    Apr 2008
    Beans
    3,317
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: How to determine which Linux partition w/ Grub controls the MBR?

    Correction:

    In case 2) one is able to boot into Mandriva. ( "chainloader" works but "configfile" does not.)

    Are you using Ubuntu 7.10 or lower ? (The Ubuntu 8.04 grub can read Mandriva but the others can not)

  2. #12
    Join Date
    Dec 2007
    Beans
    176
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: How to determine which Linux partition w/ Grub controls the MBR?

    Quote Originally Posted by caljohnsmith View Post
    Thus it seems like when I do the "find /boot/grub/stage1" command from the boot-up Grub CLI, I get the partition the MBR points to. But if I go to the Grub CLI from within one of my Linux distros and do the same command, Grub returns ALL my partitions that contain a Grub stage1 file, and not just the partition that the MBR points to.

    Can someone please either confirm or clarify this?

    find /boot/grub/stage1 command will start at / and search every directory for the file called "stage1." Another way, although not very clever, to figure out what distro is controlling your boot process would be to modify each of your menu.lst files and put a string beside the kernel line--such as vga=xxx, or somethign, doesn't really matter--then when you boot and are confronted with grub, you can hit 'e' to modify the arguments, and then you will be able to see the little string that you placed and will be able to identify your partition as such.

    hope it works out.

  3. #13
    Join Date
    Mar 2008
    Location
    California, USA
    Beans
    8,111

    Re: How to determine which Linux partition w/ Grub controls the MBR?

    Quote Originally Posted by meierfra. View Post
    Correction:

    In case 2) one is able to boot into Mandriva. ( "chainloader" works but "configfile" does not.)

    Are you using Ubuntu 7.10 or lower ? (The Ubuntu 8.04 grub can read Mandriva but the others can not)
    I started originally with 7.10 and upgraded to 8.04 successfully. My installed grub package is 0.97-29ubuntu21. You are right on the mark in that I cannot load Mandriva with "configfile" notation, but I can with "chainloader" since I have Mandriva's grub installed into its partition boot sector and not the MBR.

    When I search for menu.lst and stage2 in grub's CLI while I'm in either of my two linux distros (accessing the grub CLI with "sudo grub"), it still returns both distros. Yet doing the same thing in Grub's CLI on boot-up still returns just my Ubuntu partition only (hd0,1).

    So do I need to upgrade/reconfigure Grub or something?

  4. #14
    Join Date
    Apr 2008
    Beans
    3,317
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: How to determine which Linux partition w/ Grub controls the MBR?

    Try reinstalling grub:

    at any grub prompt:

    Code:
    root (hd0,1)
    setup (hd0)
    quit

  5. #15
    Join Date
    Mar 2008
    Location
    California, USA
    Beans
    8,111

    Re: How to determine which Linux partition w/ Grub controls the MBR?

    Quote Originally Posted by meierfra. View Post
    Try reinstalling grub:

    at any grub prompt:

    Code:
    root (hd0,1)
    setup (hd0)
    quit
    I thought this only rewrote the MBR to point to (hd0,1) and does not actually reinstall grub. I tried it anyway and it didn't change anything, so I did a full reinstall of Grub (and of course I first backed up my menu.lst); even though in Synaptic I set the "mark with complete removal" for Grub and then uninstalled Grub, still all the files were left in the /boot/grub/ folder. So I manually deleted them all, and then reinstalled Grub. But even after reinstalling, no files were created in /boot/grub! So I did a "sudo grub-install /dev/sda" and that created all my /boot/grub files except menu.lst, which was fine since I copied back the old one anyway.

    Bottom line is that after the complete reinstall everything works as expected; doing "find /boot/grub/stage1" at boot-up now returns both (hd0,1) and (hd0,3) or both linux partitions. And even better, I can now load Mandriva using the "configfile" notation.

    Just for future reference, is there a better way to reinstall Grub instead of manually deleting the /boot/grub files after uninstalling Grub and then run the grub-install command after reinstalling Grub?

    Thanks for all the help, meierfra.

  6. #16
    Join Date
    Apr 2008
    Beans
    3,317
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: How to determine which Linux partition w/ Grub controls the MBR?

    "sudo grub-install /dev/sda"
    This is probably all you had to do and that's what I should have suggested right away. The whole problem comes from the "stage2" file. "grub-install" reinstalls all stage files.

    To my defense: "setup (hd0)" does more than just changing a few numbers. It does reinstall the stage1 and stage1.5 files to the first few sectors of the MBR. Also I thought that upgrading to Hardy would have automatically upgraded all the stage files in /boot/grub. It doesn't!

    Thanks for posting your solution. Now it all makes sense to me.
    Last edited by meierfra.; June 24th, 2008 at 03:45 AM.

  7. #17
    Join Date
    Mar 2008
    Beans
    4,715
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: [SOLVED] How to determine which Linux partition w/ Grub controls the MBR?

    What is meant by "which linux controls the MBR?" I'm confused by this terminology. I thought there were many MBRs -- one for each partition and one at the beginning of each hard disk. Are we really asking, "Which partition does the MBR at the beginning of the hard disk point to?"

    Moreover, is the dd command supposed to tell you the partition in which /boot/grub/menu.lst resides?
    If so, my system seems to be a counterexample.
    When I run

    Code:
    % sudo dd if=/dev/sda  bs=1 skip=1049 count=2 | hexdump
    I get
    Code:
    0000000 0000                                   
    0000002
    But my linux partition is (hd0,2):
    Code:
    % sudo fdisk -l
    
    Disk /dev/sda: 320.0 GB, 320072933376 bytes
    255 heads, 63 sectors/track, 38913 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x48000000
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1               1           7       56196   de  Dell Utility
    /dev/sda2               8         660     5245222+   b  W95 FAT32
    /dev/sda3   *         661       38536   304238970   83  Linux
    /dev/sda4           38537       38913     3028252+   5  Extended
    /dev/sda5           38537       38913     3028221   82  Linux swap / Solaris
    I thought the dd command should return

    Code:
    00000000 ff02
    00000002
    Am I misunderstanding what the dd command is telling me?

    Thanks very much for your help.

  8. #18
    Join Date
    Apr 2008
    Beans
    3,317
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: [SOLVED] How to determine which Linux partition w/ Grub controls the MBR?

    I thought there were many MBRs -- one for each partition and one at the beginning of each hard disk.
    The whole hard drive has an MBR. A primary partition does not have an MBR. The 63 sectors before a logical partition are called the MBR of that partition. But usually if one talks about an MBR, ones means the MBR of the hard drive.

    If so, my system seems to be a counterexample.
    Could be. But are you sure that Grub is installed to the MBR of the hard drive? Maybe Grub is installed to the boot sector of /dev/sda3.

    What is the output of

    Code:
    sudo dd if=/dev/sda  bs=512  count=1| hexdump
    and

    Code:
    sudo dd if=/dev/sda3 bs=512 count=1 | hexdump

  9. #19
    Join Date
    Mar 2008
    Beans
    4,715
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: [SOLVED] How to determine which Linux partition w/ Grub controls the MBR?

    Code:
    % sudo dd if=/dev/sda  bs=512  count=1| hexdump
    1+0 records in
    1+0 records out
    512 bytes (512 B) copied, 2.9634e-05 seconds, 17.3 MB/s
    0000000 c033 d08e 00bc 8e7c 8ec0 bed8 7c00 00bf
    0000010 b906 0200 f3fc 50a4 1c68 cb06 b9fb 0004
    0000020 bebd 8007 007e 7c00 0f0b 1085 8301 10c5
    0000030 f1e2 18cd 5688 5500 46c6 0511 46c6 0010
    0000040 41b4 aabb cd55 5d13 0f72 fb81 aa55 0975
    0000050 c1f7 0001 0374 46fe 6610 8060 107e 7400
    0000060 6626 0068 0000 6600 76ff 6808 0000 0068
    0000070 687c 0001 1068 b400 8a42 0056 f48b 13cd
    0000080 839f 10c4 eb9e b814 0201 00bb 8a7c 0056
    0000090 768a 8a01 024e 6e8a cd03 6613 7361 fe1e
    00000a0 114e 850f 000c 7e80 8000 840f 008a 80b2
    00000b0 82eb 3255 8ae4 0056 13cd eb5d 819c fe3e
    00000c0 557d 75aa ff6e 0076 8ae8 0f00 1585 b000
    00000d0 e6d1 e864 007f dfb0 60e6 78e8 b000 e6ff
    00000e0 e864 0071 00b8 cdbb 661a c023 3b75 8166
    00000f0 54fb 5043 7541 8132 02f9 7201 662c 0768
    0000100 00bb 6600 0068 0002 6600 0868 0000 6600
    0000110 6653 6653 6655 0068 0000 6600 0068 007c
    0000120 6600 6861 0000 cd07 5a1a f632 00ea 007c
    0000130 cd00 a018 07b7 08eb b6a0 eb07 a003 07b5
    0000140 e432 0005 8b07 acf0 003c fc74 07bb b400
    0000150 cd0e eb10 2bf2 e4c9 eb64 2400 e002 24f8
    0000160 c302 6e49 6176 696c 2064 6170 7472 7469
    0000170 6f69 206e 6174 6c62 0065 7245 6f72 2072
    0000180 6f6c 6461 6e69 2067 706f 7265 7461 6e69
    0000190 2067 7973 7473 6d65 4d00 7369 6973 676e
    00001a0 6f20 6570 6172 6974 676e 7320 7379 6574
    00001b0 006d 0000 6200 997a 0000 4800 0000 0100
    00001c0 0001 fede 063f 003f 0000 b708 0001 0000
    00001d0 0701 fe0b 93bf b747 0001 124d 00a0 0080
    00001e0 9481 fe83 ffff c994 00a1 a2f4 2444 fe00
    00001f0 ffff fe05 ffff 6c88 24e6 6a39 005c aa55
    0000200
    % sudo dd if=/dev/sda3 bs=512 count=1 | hexdump
    1+0 records in
    1+0 records out
    0000000 48eb 0090 0000 0000 0000 0000 0000 0000
    0000010 0000 0000 0000 0000 0000 0000 0000 0000
    *
    0000030 0000 0000 0000 0000 0000 0000 0000 0203
    0000040 00ff 8000 4314 08e6 0800 90fa f690 80c2
    0000050 0275 80b2 59ea 007c 3100 8ec0 8ed8 bcd0
    0000060 2000 a0fb 7c40 ff3c 0274 c288 be52 7d7f
    0000070 34e8 f601 80c2 5474 41b4 aabb cd55 5a13
    0000080 7252 8149 55fb 75aa a043 7c41 c084 0575
    0000090 e183 7401 6637 4c8b be10 7c05 44c6 01ff
    00000a0 8b66 441e c77c 1004 c700 0244 0001 8966
    00000b0 085c 44c7 0006 6670 c031 4489 6604 4489
    00000c0 b40c cd42 7213 bb05 7000 7deb 08b4 13cd
    00000d0 0a73 c2f6 0f80 ea84 e900 008d 05be c67c
    00000e0 ff44 6600 c031 f088 6640 4489 3104 88d2
    00000f0 c1ca 02e2 e888 f488 8940 0844 c031 d088
    0000100 e8c0 6602 0489 a166 7c44 3166 66d2 34f7
    0000110 5488 660a d231 f766 0474 5488 890b 0c44
    0000120 443b 7d08 8a3c 0d54 e2c0 8a06 0a4c c1fe
    0000130 d108 6c8a 5a0c 748a bb0b 7000 c38e db31
    0000140 01b8 cd02 7213 8c2a 8ec3 4806 607c b91e
    0000150 0100 db8e f631 ff31 f3fc 1fa5 ff61 4226
    0000160 be7c 7d85 40e8 eb00 be0e 7d8a 38e8 eb00
    0000170 be06 7d94 30e8 be00 7d99 2ae8 eb00 47fe
    0000180 5552 2042 4700 6f65 006d 6148 6472 4420
    0000190 7369 006b 6552 6461 2000 7245 6f72 0072
    00001a0 01bb b400 cd0e ac10 003c f475 00c3 0000
    00001b0 0000 0000 0000 0000 0000 0000 0000 0000
    *
    00001f0 0000 0000 0000 0000 0000 0000 0000 aa55
    0000200
    512 bytes (512 B) copied, 2.4445e-05 seconds, 20.9 MB/s

  10. #20
    Join Date
    Apr 2008
    Beans
    3,317
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: [SOLVED] How to determine which Linux partition w/ Grub controls the MBR?

    unutbu: You have Grub installed on /dev/sda3 and not on /dev/sda. I didn't spend enough time to figure out what boot loader is installed in the MBR. Do you know? Is it the original Windows MBR?

    If you run

    Code:
    sudo dd if=/dev/sda   bs=512  count=1| hexdump -c
    sudo dd if=/dev/sda3  bs=512  count=1| hexdump -c
    you will see some human readable lines.
    For example the /dev/sda3 output on lines 17-19 will say "Grub Geometry Hard Disk Read Error".

    My code to identify the controlling linux does not work if grub is installed on a partition. But if grub is not installed on the MBR, then usually the partition with the boot flag is in charge of the booting. So you don't need any tricky code.

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •