Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Absolute Beginner Talk
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Absolute Beginner Talk
The perfect starting place to find out more about computers, Linux and Ubuntu.

 
Thread Tools Display Modes
Old October 29th, 2009   #1
ranch hand
Skinny Extra Sweet Ubuntu
 
ranch hand's Avatar
 
Join Date: Aug 2008
Location: South East Montana
Beans: 3,206
Ubuntu 8.04 Hardy Heron
Grub2 introduction

DON'T PANIC

There is a lot of great information on grub2 on this forum.

I wrote this up to give folks a flying start. This will not make you an expert but it will, hopefully, get you headed in the right direction.

A lot of people have trouble, right after installation, with other OS' being missing from the menu. The first thing to do for this is go to your terminal and;
Code:
sudo update-grub
This is all it takes a majority of the time.
EDIT (10-28-09)
There is another way to update grub;
Code:
sudo grub-mkconfig
This is supposed to be the default and will, I believe, soon replace update-grub altogether.
END EDIT

Grub2 is completely different from grub-legacy. If you are using grub2 be prepared to learn something new.


The menu that you see on the screen when you boot up comes from the /boot/grub/grub.cfg file.


The /boot/grub/grub.cfg file is generated everytime “update-grub” is run. This is run everytime you get a kernal update and many times when you get a grub update. It does not make sence to edit this file.


Grub.cfg is generated by scripts in /etc/grub.d.


00_header gets the ball rolling and gets your timeout and hidden menu information for the menu.


05_debian-theme sets up how your menu looks on the screen.


10_linux is the one that gives you the menu entry for the OS that you are on.


20_memtest86+ is what sets the memtest on your menu.


30_os-prober is what is responcible for finding the rest of your OS'.


40_custom is designed so that you can make custom entries.


Grub2 gets its time out information and sets up a hidden menu for you in /etc/default/grub.


If you need to edit a menu entry that does not work do not mess with grub.cfg. It is silly to do so. It will be over written.


Go to /etc/grub.d and add to the 40_custom file. For instance;
30_os-prober does not generate a functional menu entry for my Mandriva installs. So I have a custom entry that works every time and comes right up on the menu every time. It is not over written because it is regenerated every time that “update-grub” is run.
Code:
    menuentry "linux-nonfb (on /dev/sda12)" {
    insmod ext2
    set root=(hd0,12)
    search --no-floppy --fs-uuid --set c23ad2ca-67a5-4a42-8fcc-3baa6d8e454e
    linux /boot/vmlinuz BOOT_IMAGE=linux-nonfb root=UUID=c23ad2ca-67a5-4a42-8fcc-3baa6d8e454e resume=UUID=59fe476e-6d4f-e390-ced9-f29328538dfc
    initrd (hd0,11)/boot/initrd.img
}
As you can see the partition is defined as being in two different places in this entry. It will not boot. The entry below will boot very well indeed.

Code:
menuentry "Mandriva-Gnome" {
        linux (hd0,12)/boot/vmlinuz
        initrd (hd0,12)/boot/initrd.img
}
This also works very well for your non-grub2 Ubuntu OS'.


I use a slightly different entry for grub2 Ubuntu installs;
Code:
menuentry "Kinky-Grub2-A2 on sda10 2.6.31-11-generic" {
        set root=(hd0,10)
        linux /vmlinuz root=/dev/sda10 so quiet splash
        initrd /initrd.img
}
This entry works even if you change the OS on the partition.

Your custom entries must be in the proper form. The first thing to do is start your favorite text editor (I use gedit). Go to preferences and set it so that there is NO test wrapping.

Then, in your 40_custom file put in an entry such as;
Code:
echo "Adding Kinky-Grub2-A2 on sda10 (2.6.31-11-generic)" >&2 
cat << EOF
menuentry "Kinky-Grub2-A2 on sda10 2.6.31-11-generic" {
        set root=(hd0,10)
        linux /vmlinuz root=/dev/sda10 so quiet splash
        initrd /initrd.img
}
EOF
That is the entire entry for that OS. It is the one that I use for experimenting on grub2. The part that does the work is between the { }s. Make sure that they are where they belong.


If you save this file as 06_custom it will appear at the top of menu you see on the screen. If you save it as 40_custom it will appear at the bottom of menu you see on the screen.


Now, what is the advantage of this rigamarole compared to grub-leagacy.


Well, if you have three OS' on your drive and you set up a custom menu you do not need any other menu entries at all. So you change the permissions on 10_linux, 20_memtest86+, 30_custom so that they are not executable. They will not run when “update-grub” is run and so the onoy thing on your menu is your custom entries. There is nothing that can mess with these entries except you.


You must remember to run;
Code:
sudo update-grub
Everytime you do anything that is to change your menu. This will overwrite your /boot/grub/grub.cfg file and thus the menu that shows up on your screen.


Here are some links, some more useful than others, that I have collected.

Some grub2 links;


http://members.iinet.net/~herman546/p20.html

http://ubuntuforums.org/showthread.php?t=1195275

http://ubuntuforums.org/showthread.php?t=1302743

http://ubuntuforums.org/showthread.php?t=1287602

http://grub.enbug.org/

http://grub.enbug.org/Manual

http://grub.enbug.org/CommandList

https://wiki.ubuntu.com/Grub2#Adding...0to%20Grub%202

https://wiki.ubuntu.com/Grub2#Recove...20via%20LiveCD

http://members.iinet.net/~herman546/p20/GRUB2%20CLI%20Mode%20Commands.html#cli_loopback

http://members.iinet.net/~herman546/p20/GRUB2%20Splashimages.html

http://ubuntuforums.org/showthread.php?t=1287602

http://ubuntuforums.org/showthread.php?t=1287967

https://help.ubuntu.com/community/Gr...LI%20to%20Boot

In case grub2 is just too much, you may want to take a look at this;

http://ubuntuforums.org/showthread.php?t=1298932

Some other links that are just interesting and may help or inspire some one;

http://ubuntuforums.org/showpost.php...9&postcount=16

http://ubuntuforums.org/showthread.p...98#post8100252

http://ubuntuforums.org/showthread.php?t=1288604

http://ubuntuforums.org/showthread.php?t=1291280


HAVE FUN
__________________
Dell 480 XPS 3G ram Quad Core 2.40GHz 3x320G HDD, 320G External, GRUB 2 Introduction

Last edited by ranch hand; 1 Day Ago at 11:28 AM..
__________________
Dell 480 XPS 3G ram Quad Core 2.40GHz, Radeon HD 2400 PRO, Audigy1, 3x320G HDD, 320G External, [ubuntu] Grub2 introduction

Last edited by ranch hand; November 19th, 2009 at 11:36 AM..
ranch hand is offline   Reply With Quote
Old October 29th, 2009   #2
Muffinabus
Gee! These Aren't Roasted!
 
Join Date: Jun 2007
Location: Chicago, Illinois
Beans: 160
Re: Grub2 introduction

I just have one quick question. If Grub2 automatically detects my Windows 7 drive, will it do anything to the Windows MBR? I liked Grub legacy because I could edit the file knowing it would only affect this hard drive, now I'm unsure. I don't want Grub 2 to touch that hard drive AT ALL.

To clarify, I want Grub 2 to be able to boot to my separate Windows 7 drive, but don't want it to modify the Windows 7 MBR.
Muffinabus is offline   Reply With Quote
Old October 29th, 2009   #3
ranch hand
Skinny Extra Sweet Ubuntu
 
ranch hand's Avatar
 
Join Date: Aug 2008
Location: South East Montana
Beans: 3,206
Ubuntu 8.04 Hardy Heron
Re: Grub2 introduction

While I have no problem with you having Win JerryLewis Pro on your box, I do not, and will not on mine.

So I am not the best guy to advise on this. Hopefully one of the other guys from testing will jump in here.

I believe, though, that you can set it up the same way you had it in grub-legacy.
__________________
Dell 480 XPS 3G ram Quad Core 2.40GHz, Radeon HD 2400 PRO, Audigy1, 3x320G HDD, 320G External, [ubuntu] Grub2 introduction
ranch hand is offline   Reply With Quote
Old November 1st, 2009   #4
darthmob
A Carafe of Ubuntu
 
Join Date: May 2008
Location: Germany
Beans: 146
Ubuntu 9.10 Karmic Koala
Send a message via ICQ to darthmob Send a message via MSN to darthmob
Re: Grub2 introduction

Damn that's a lot to read into. Seems like things have taken a few steps into the direction of way more complicated.

Luckily changing the timeout of the grub menu is still a matter of changing one line in a config. Change it in /etc/default/grub and execute a grub-update via terminal.
darthmob is offline   Reply With Quote
Old November 1st, 2009   #5
ranch hand
Skinny Extra Sweet Ubuntu
 
ranch hand's Avatar
 
Join Date: Aug 2008
Location: South East Montana
Beans: 3,206
Ubuntu 8.04 Hardy Heron
Re: Grub2 introduction

Quote:
Originally Posted by darthmob View Post
Damn that's a lot to read into. Seems like things have taken a few steps into the direction of way more complicated.

Luckily changing the timeout of the grub menu is still a matter of changing one line in a config. Change it in /etc/default/grub and execute a grub-update via terminal.
When you consider how many new types of bootable storage hardware keeps turning up, and different file systems, grub2 has the flexibility to deal with these things in the future.

Grub-legacy was, and is, a fantastic bootloader. I think that grub2 is going to be better.

It is not really that complicated. It is very different and new. If you dig up the Karmic Testing Forum you will see a whole lot of people real bewildered when alpha2 came out and we got grub2. I have 91 threads saved from that forum on grub2. It really does grow on you,

On thing that is not more complicated is updating multiboot systems. If you have 4 flavors on your box and one gets a kernel update you have to go in and edit the /boot/grub/menu.lst of the OS that is the boot/root (assuming it is not hte one with the new kernel).

Grub2 will pick up that kernel by simply running update-grub. If you use the right type of menu entry in a custom menu it will not need updated at all (this is what I do).
__________________
Dell 480 XPS 3G ram Quad Core 2.40GHz, Radeon HD 2400 PRO, Audigy1, 3x320G HDD, 320G External, [ubuntu] Grub2 introduction
ranch hand is offline   Reply With Quote
Old November 1st, 2009   #6
oldos2er
Ubuntu addict and loving it
 
oldos2er's Avatar
 
Join Date: Jul 2007
Location: Cheyenne, WY, USA
Beans: 4,511
Ubuntu 9.10 Karmic Koala
Re: Grub2 introduction

ranch hand, thank you for posting this.
__________________
Ann

--That is not dead which can eternal lie,
And with strange aeons even death may die.
oldos2er is offline   Reply With Quote
Old November 1st, 2009   #7
ranch hand
Skinny Extra Sweet Ubuntu
 
ranch hand's Avatar
 
Join Date: Aug 2008
Location: South East Montana
Beans: 3,206
Ubuntu 8.04 Hardy Heron
Re: Grub2 introduction

I like the tiered snow fence they use in WY. I tell folks it is where you sit to watch the deer and the antelope play. Well, they do look like bleachers.
__________________
Dell 480 XPS 3G ram Quad Core 2.40GHz, Radeon HD 2400 PRO, Audigy1, 3x320G HDD, 320G External, [ubuntu] Grub2 introduction
ranch hand is offline   Reply With Quote
Old November 1st, 2009   #8
LewRockwell
Chocolate Ubuntu Mocha Blend
 
Join Date: Jun 2009
My beans are hidden!
Re: Grub2 introduction

we've only been linking to two places:

https://help.ubuntu.com/community/Grub2

http://ubuntuforums.org/showthread.php?t=1195275


there are some errors in one and/or both but it's mostly common sense

(like in one place "sudo apt-get update" is used...where "sudo update=grub" should have been noted)

.
__________________
Link: Help Vampires? * * * Please Edit First Post Title With "[SOLVED]" When It Is!
MANDATORY INFORMATION: make, model/build number, OSes, software, accessories
/customizations/modifications/peripherals/etc...and a DETAILED account of difficulties!
LewRockwell is offline   Reply With Quote
Old November 1st, 2009   #9
timsdeepsky
5 Cups of Ubuntu
 
timsdeepsky's Avatar
 
Join Date: Jan 2008
Location: Midwest
Beans: 26
Ubuntu 9.10 Karmic Koala
Re: Grub2 introduction

Thanks ranch hand....
Although this process did not work for me,,,,it worked on my sons computer....My XPS would fail to launch grub2 at all....I could install 9.04,,and upgrade to 9.10,,,,but this was not using grub2....This seemed to originate from my using 2 operating systems on separate hard drives....I ended up unplugging one hard drive,,,,installing 9.10,,,,then plugging it back in and running
Code:
sudo update-grub
....This worked perfect for me....
__________________
Deepsky....I woke up one day feeling a little darker than usual....My inevitable midlife search for meaning....http://timcline.org/
timsdeepsky is offline   Reply With Quote
Old November 1st, 2009   #10
ranch hand
Skinny Extra Sweet Ubuntu
 
ranch hand's Avatar
 
Join Date: Aug 2008
Location: South East Montana
Beans: 3,206
Ubuntu 8.04 Hardy Heron
Re: Grub2 introduction

Wow, that is interesting.

I am actually having a problem booting another drive. I may try wiping my device map and trying that.

Grub2 is new and we have a lot to learn.

Upgrading is pretty rough. There are a lot of changes and some of the residual stuff from 9.04 is not real compatible with 9.10.
__________________
Dell 480 XPS 3G ram Quad Core 2.40GHz, Radeon HD 2400 PRO, Audigy1, 3x320G HDD, 320G External, [ubuntu] Grub2 introduction
ranch hand is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:59 AM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry