GRUB and MBR questions from a real newbie

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Husse

Re: GRUB and MBR questions from a real newbie

Post by Husse »

Unless I misunderstand this you put grub in (hd2) - grub counts from zero so thats the MBR of the Vista disk - and Vista can be booted, the installer takes care of that
That should work....
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Fred

Re: GRUB and MBR questions from a real newbie

Post by Fred »

You know, I have often wondered if whoever wrote grub knew what kind of ongoing problems would result from numbering from zero. Or maybe they did and it was just a cruel practical joke. :-)

Oh well, isn't life grand. :-)

Fred
Fred

Re: GRUB and MBR questions from a real newbie

Post by Fred »

Rimmsy,

I see you are using a separate /boot partition, which is fine. I do it all the time. If you install and everything seems to be working ok but you aren't getting the pretty Mint boot screen, don't panic. There is a simple fix if this happens.

Enjoy,

Fred
Husse

Re: GRUB and MBR questions from a real newbie

Post by Husse »

If it is sdc3 it should be root (hd2,2)
Fred

Re: GRUB and MBR questions from a real newbie

Post by Fred »

Rimmsy,

Lets back up a bit and check some things. Run the live cd, open Gparted and post a screen shot of each of your hard drives so we can see what we are really working with.

Also, look on your /boot partition and open a file there called /boot/grub/menu.lst. Copy and paste the contents of that file so we can take a look at it.

Fred
User avatar
atlef
Level 4
Level 4
Posts: 306
Joined: Sun Nov 18, 2007 8:20 am
Location: Stavanger NORWAY

Re: GRUB and MBR questions from a real newbie

Post by atlef »

Would just point out that windows IS stupid when it comes to mbr/bootloader placement. And we know that most likely your win install has installed this to sda not sdc which also might cause a problem.

atlef.
Husse

Re: GRUB and MBR questions from a real newbie

Post by Husse »

I'm running out of time so I don't have the time to read through the topic
But Rimmsy read the grub wiki carefully and you will understand (I hope - this is hard) how to cope with your grub situation
http://www.linuxmint.com/wiki/index.php ... _your_grub
Fred

Re: GRUB and MBR questions from a real newbie

Post by Fred »

Rimmsy,

I haven't had much time to be on the computer in the last couple days. I see muskratmx has taken the time to give you a lot of really good advice. I suggest that you follow it. :-)

Anything you don't know is hard. Anything that you know is easy. Once learned, it will be easy. I promise. :-)

Fred
Husse

Re: GRUB and MBR questions from a real newbie

Post by Husse »

I think you're doing fine without me :)
Just a note
Then it inserts a complete system onto the MBR
No, no - but this is (probably) just a slip of the tongue
MBR is one sector 512 bytes so it does not contain much :)
Just a partition table and a "pointer"
Google for it if you're interested
Fred

Re: GRUB and MBR questions from a real newbie

Post by Fred »

Husse,

You know we couldn't do without you. Besides, who is going to keep me honest and correct my silly mistakes? :-)

Enjoy life,

Fred
Husse

Re: GRUB and MBR questions from a real newbie

Post by Husse »

@ Muskrat/Steve
You write
Notice the two map lines. If windows was in the primary master position it would only have one map line.
I checked the grub manual before advising someone else and it does not say anything about that
This is all there is about that
13.3.23 map
— Command: map to_drive from_drive

Map the drive from_drive to the drive to_drive. This is necessary when you chain-load some operating systems, such as DOS, if such an OS resides at a non-first drive. Here is an example:

grub> map (hd0) (hd1)
grub> map (hd1) (hd0)


The example exchanges the order between the first hard disk and the second hard disk. See also DOS/Windows.
I have not explored this specific part of grub - it's a fact of life that people install Win before Linux....
so the need is not pressing
I looked a bit more and found another manual that was really interesting (for a nerd :))
http://www.linuxselfhelp.com/gnu/grub/h ... rub_4.html
Husse

Re: GRUB and MBR questions from a real newbie

Post by Husse »

Thanks for this post - I have no experience at all of Win on the second disk. I think XP and Vista can handle it, but I may be wrong. Earlier versions than XP definitely can't
OK - I wrote "pointer" in MBR and knew it really is a minute program. If that's the kernel of grub I stand corrected (to an extent) :)
However for both Win and Linux I have never contemplated MBR as anything but a partition table and a way to find the "real" boot loader, so I did not pay enough attention to it
This was interesting though
There is an alternative way of doing things, but it's usually used eternally on disks, allowing you to install and boot windows to the second or third partition. It's called hiding partitions. But that's another topic for another day.
Solves a problem for another guy, I was looking for the way to "swap partitions" so the stupid Win thinks it's in C
//Edit by husse/Oh no - it did not, seems to be only if there are two Win partitions on the disk.
Must find out if grub can help with Windows in another partition than the first//
Grub is so hard to understand that you almost get a head ache :) but I think I understand it decently but for the chainload thing which I'm beginning to grasp
Fred

Re: GRUB and MBR questions from a real newbie

Post by Fred »

muskratmx,

Greetings sir,

I read your comments above with interest. Noticed this:
Chainloading is one area, which I've still to conquer entirely. I can chainload windows now with little problems. But haven't been able to chainload Linux. By theory one can install a bootloader to the partition record of a given partition and chainload from the bootloader in MBR to the bootloader in the partition record. I haven't acomplished that yet.
Maybe this will help you a little bit. I have a computer that currently has 2 copies of Linux Mint 4 KDE CE, Kubuntu, Sidux, which I just added, and Sabayon. This is the main computer that my wife uses also. She likes Mint 4 KDE CE, so I have a separate install for her. I have a habit of breaking systems and then having to fix them, trying to do strange and unusual things. As you can imagine, this doesn't go over well with her when she wants to do something important, like read the obituaries. :-)

I did have separate boot and home partitions, but have now changed that. I put everything in / for each installation. And I now have a separate partition for booting only. A master boot you might say. It is not associated with any of the installs. You could use the boot of one of the installs as the master boot but this way the boot capability isn't tied to any one install. I call this partition /gboot.

Here is the layout. I have 1.5 Gig physical ram and two hard drives. They are both ide but it works just fine with sata too. To hold down on confusion, I will refer to partitions with the convention sdxx since thats the way most distros do now. I will refer to them as (hdx,x) when talking about grub.

Note: Edited grub notation to make it consistent with actual commands needed.

sda - Boot drive

sda1 - 300 MB - /gboot - ext2
sda2 - 1 Gig - swap
sda3 - 14 Gig - / - Mint 4 KDE - ext3
sda5 - 14 Gig - / - Mint 4 KDE - ext3
sda6 - 14 Gig - / - Kubuntu 7.10 - ext3
sda7 - 14 Gig - / - Sabayon - ext3
sda8 - 14 Gig - / - Sidux - ext3
sda9 - 14 Gig - /home/denise/My_Data - ext3
sda10 - 14 Gig - /home/fred/Backup - ext3

sdb - Slave drive

sdb1 - 1 Gig - swap
sdb2 - 42 Gig - /home/fred/My_Data

I cross mount sda9 on my Mint 4 KDE as /home/fred/Denise
I cross mount sdb2 on her Mint 4 KDE as /home/denise/Fred_Stuff

Ok, let's get to the meat of it. I like the Mint 4 grub so that's what I used. I copied the entire Mint 4 /boot partition to /gboot. You can delete the kernels from /gboot later if you wish. Doesn't help or hurt, as they won't be used anyway.

You need to install grub to the Mint 4 install you just copied the /boot from. In my case I typed:

sudo grub

root (hd0,2)

setup (hd0,2)

quit

You need to copy /etc/grub/message.mint to /gboot/grub/. Edit /gboot/grub/menu.lst and change the gfxboot line to gfxboot=/grub/message.mint . This will give you the nice Mint 4 boot screen.

While you are there you can go ahead and put your chainload lines in the /gboot/grub/menu.lst. They can go either before or after the Automagic kernel section. I put mine in before. You don't need any other boot stanzas that you might already have there, so erase them. Example:

EDIT: 8/1/2009 - The later versions of grub no longer need the "makeactive" line in the chainload stanza for booting Linux. Remove it from the below examples.

# lots of stuff

# gfxmenu=/etc/grub/message.mint

gfxmenu=/grub/message.mint

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
# timeout 10

timeout 15


# Pretty colours
color cyan/blue white/blue

## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive editing
# control (menu entry editor and command-line) and entries protected by the
# command 'lock'
# e.g. password topsecret
# password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret

#
# examples
#
# title Windows 95/98/NT/2000
# root (hd0,0)
# makeactive
# chainloader +1
#
# title Linux
# root (hd0,1)
# kernel /vmlinuz root=/dev/hda2 ro
#

#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

title Mint 4 - KDE CE Denise
root (hd0,2)
makeactive
chainloader +1

title
root

title Mint 4 - KDE CE Fred
root (hd0,4)
makeactive
chainloader +1

title
root

title Kubuntu 7.10
root (hd0,5)
makeactive
chainloader +1

title
root

title Sabayon
root (hd0,6)
makeactive
chainloader +1

title
root

title Sidux
root (hd0,7)
makeactive
chainloader +1

# The reason I use the "makeactive" line is some boot
# systems won't boot without the partition being made
# active. So I always put it in even though it isn't needed
# most of the time.

### BEGIN AUTOMAGIC KERNELS LIST

# lots of stuff!

## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options below
## ## End Default Options ##

# deleted automagic boot stanzas

### END DEBIAN AUTOMAGIC KERNELS LIST

# deleted static boot stanzas

Ok. here comes the fun and mistake prone part. :-)

You must install Mint grub to the mbr of sda pointing to /gboot. In Mint open a terminal:

sudo grub

root (hd0,0)

setup (hd0)

quit

When you install a system, install grub to the partition that /boot is in for that installation. In my case that is the / partition. This can usually be done as part of the install. If not, choose not to install grub anywhere.

In some cases the Mint grub and the new install grub will not cooperate. As an example, Sidux and Kubuntu. When I tried to boot Sidux with this setup it booted fine, no problem. Kubuntu, on the other hand didn't like the Mint Grub. If you have a system that won't boot then you need to install the Mint grub to the partition /boot is in for the problem install. In my case with Kubuntu I did this in a Mint terminal.

sudo grub

root (hd0,5)

setup (hd0,5)

quit

From now on you can change distros without affecting your master boot setup. The only thing you will have to do is change the title line in /gboot/grub/menu.lst to the new distro name. And maybe do the above as I had to do for Kubuntu. Most distros are happy with Mint grub.

For the sake of being more complete, I should add. Edit each distro's /boot/grub/menu.lst and remove the static boot stanzas that appear there to clean up your boot screens some. I also reduce the time given for the default boot. This keeps the overall unattended boot time lower.

# timeout 10

timeout 4

I hope this sheds some light on the chainload issue. Bye-the-way, in case you haven't figured it out, Denise is my lovely bride of 45+ years. :-)

Enjoy,

Fred

EDIT: Don't forget. When you install another distro that formats its' partition on install, you will have to correct the UUIDs in /etc/fstab of all the existing systems that use UUIDs. You may have to do the same in /boot/grub/menu.lst also.
Last edited by Fred on Sat Aug 01, 2009 8:47 am, edited 7 times in total.
Fred

Re: GRUB and MBR questions from a real newbie

Post by Fred »

Look at chainloading like a system of pointers. That is not exactly correct but it simplifies it.

You install grub to the mbr of a bootable storage device. That grub points to a menu, usually located where the kernel you wish to boot is located. You then point to the kernel you wish to boot by selecting it from the menu.

When you chainload you point to another partition to boot. If grub is installed in that partition, it then points to the menu associated with that grub. You then point to the kernel you wish to boot and select it from that menu. You are now off and running.

The setup command tells where to install the bootable grub kernel. The root command tells where the menu associated with that grub kernel is. If you look at it like that it isn't quite as confusing.

Using a separate, independent boot partition and chainloading is a good way to boot an otherwise unbootable storage device like a usb stick or usb removable drive. A lot of BIOSs won't boot usb devices. This is especially handy if you don't have the space on a hard drive with a Windows install to install Linux. You can always free up 300 MB for a /gboot partition and boot Windows and the external drive from there by chainloading.

Fred
Last edited by Fred on Sun Mar 09, 2008 3:20 am, edited 3 times in total.
Fred

Re: GRUB and MBR questions from a real newbie

Post by Fred »

muskratmx,

You are welcome sir. Glad I could be of service my friend.:-)

Fred
Fred

Re: GRUB and MBR questions from a real newbie

Post by Fred »

For those that want a little more depth about how the grub process works, I decided to add this breakdown.

Actually it is pretty interesting.... kinda. :-)

The system is made up of 3 or optionally 4 parts. They work together to boot a main kernel or another bootable kernel or device.

1) Stage one is the kernel. it is very small. It must fit into just over 400 bytes of space. This is the part that is bootable and goes into the mbr of a drive or partition.

2) Stage 1.5 is optional, although almost all the implementations I am familiar with now use a stage 1.5. Stage 1.5 goes in the first few KB of the drive or partition after the mbr. Stage 1.5 is a translation module that knows what kind of file system is in use, where stage 2 and the menu.lst are, and tells the grub kernel how to load stage 2.

Stage 2 then calls the splash or graphic screens and menu.lst, and translates the predetermined options and user's selection into a boot command sequence that is passed on to another bootable kernel. This could be a Linux kernel, another Grub kernel, or just about any other bootable loader. At this point Grub's job is done and it gracefully exits and awaits another command.

Having said that, the only part the user usually sees when everything is working right is the boot screen with the user options. That is why I like to think of it in terms of pointers from kernel to menu to kernel. It just makes it easier for me to keep my small mind wrapped around the concepts. :-)

Fred
Locked

Return to “Installation & Boot”