Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
03-10-2010, 07:43 PM
|
#1
|
LQ Newbie
Registered: May 2007
Location: Palo Alto, CA, USA
Posts: 3
Rep:
|
How does Grub2 find the grub.cfg file?
How does Grub2 find the grub.cfg file?
I have (among others) these partitions:
/dev/sda5 'newsys' - my current system partition (Ubuntu Karmic, 64-bit)
/dev/sda2 'oldsys' - the original system partition
/dev/sda1 'boot' - mounted at /boot when running 'newsys'
'boot' and 'oldsys' both have copies of Grub2.
The two copies of grub.cfg are identical except for a
menuentry title, so I can tell which one is being used.
When I boot, the grub menu shown is the one from 'oldsys'.
(Running 'fdisk -l' shows that /dev/sda1 ('boot') is the "Boot"
partition, but I understand that is not relevant for Grub.)
So my problem is that I am otherwise done with 'oldsys'
and I want to delete it, but I can't because
it seems to be used in the boot process.
Questions:
(1) How does Grub2 find the grub.cfg file?
(Is it in the MBR's bootloader code?)
(2) Can I tell which one it will find without actually booting?
(3) And, most importantly, how can I get Grub2 to use 'boot'
instead of 'oldsys' ?
Thanks,
-LenW
|
|
|
03-11-2010, 12:04 PM
|
#2
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809
|
there is a generic answer to this:
Any SW--application, utility, etc.--is programmed to specify where it is supposed to look for its files. This is often done in configuration files that are read in at the start of the program.
In the case of GRUB 0.97 (Why did they go to 2 if they couldn't finish 1??), the location of /boot/grub/menu.lst is "hard-coded" into the stage-I code when GRUB is installed. (Stage-I being what goes in the MBR.) I would assume that GRUB-2 does something similar----reading the manual would be the place to start.
|
|
|
03-11-2010, 12:06 PM
|
#3
|
Senior Member
Registered: Dec 2007
Location: In front of my LINUX OR MAC BOX
Distribution: Mandriva 2009 X86_64 suse 11.3 X86_64 Centos X86_64 Debian X86_64 Linux MInt 86_64 OS X
Posts: 2,369
Rep:
|
What do you mean by oldsys and newsys ?
Did you install UBUNTU Karmic twice or do you an other version of Ubuntu installed ?
Which kernels are mentioned in the boot options from oldsys or newsys or both ?
|
|
|
03-11-2010, 12:15 PM
|
#4
|
LQ 5k Club
Registered: May 2003
Location: London, UK
Distribution: Fedora40
Posts: 6,154
|
I am still fighting with grub2 ( actually it is called "1.97 Beta-4" but it is certainly not "Grub legacy" ! ) but take a look here: https://help.ubuntu.com/community/Grub2
Scroll down to "Reinstalling grub2".
Remember, if you edit any of the scripts in /etc/grub.d/ grub2 will fail without any error message if there is a trailing space on any line (except comments?) in those scripts.
Make sure you have a live CD handy for system rescue in case of errors.
Good luck.
PS: And welcome to LQ!
Last edited by tredegar; 03-11-2010 at 12:18 PM.
|
|
|
03-11-2010, 05:08 PM
|
#5
|
LQ Newbie
Registered: May 2007
Location: Palo Alto, CA, USA
Posts: 3
Original Poster
Rep:
|
Thanks for your help. I did look back over the docs
(the online info files) and decided that I should try (as root):
grub-setup -r '(hd0,1)' /dev/sda
I was diappointed to find that the MBR hadn't changed.
But I thought I would try rebooting anyway .... and ....
IT WORKED !! - The Grub menu came from my 'boot' partition !
I then compared my entire /boot directory tree with a backup.
The ONLY change was removal of an empty file:
/boot/grub/setup_left_core_image_in_filesystem
For totally gruesome completeness, I put back the empty file
and rebooted again - STILL boots from 'boot' Hurray!!
So it is still a mystery as to what tells grub where to find
grub/grub.cfg .
I can proceed to delete the obsolete partition, but I'd sure
like to know what is going on.
Any more thoughts? Maybe I'll try the help-grub list.
I'll let you know if I find anything.
Cheers,
-LenW
PS Not sure if this thread should be marked "Solved"
- I believe my problem is solved, but I still can't answer the question in the title
BTW, the 'oldsys' partition is the same O/S . It came with the system and
included the /boot directory. I built 'newsys' and 'boot' .
Last edited by LenW; 03-11-2010 at 05:17 PM.
|
|
|
03-11-2010, 09:34 PM
|
#6
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809
|
Perhaps GRUB-2 puts some things in stage-II?
When you install a bootloader, there is code that goes in the MBR, but that usually links to more code that is beyond the MBR----in the first 63 sectors of the drive (before the first partition). I have no clue as to the details of how grub-2 works in this regard.
|
|
|
03-12-2010, 12:56 AM
|
#7
|
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,637
Rep:
|
|
|
|
03-12-2010, 02:40 PM
|
#8
|
LQ Newbie
Registered: May 2007
Location: Palo Alto, CA, USA
Posts: 3
Original Poster
Rep:
|
BINGO!! I of course have no record of what those 63 sectors were
before I ran grub-setup, I tried to recreate the old data
by running grub-setup again again with -r '(hd0,2)'
And indeed the only change was that byte 0x414 = 1044 changed from
0x00 to 0x01. (BTW, about 50 of the 63 sectors were used.)
So I know that grub-setup does make its change in that first ("hidden")
track. BUT, I also know that I did not successfully recreate the old
data because trying to boot threw me into a "grub rescue>" prompt.
I managed to climb out of that tiger-trap, and another grub-setup fixed it.
I suspect the remaining confusion may involve the fact that on
'oldsys' the grub dir is /boot/grub while on 'boot' it's just /grub .
So I don't quite understand what's going on, but it's close enough for me,
and I'm marking this thread as "Solved" .
Thanks muchly,
-LenW
|
|
|
03-15-2010, 03:28 AM
|
#9
|
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,637
Rep:
|
Btw. GRUB does have a find command to find files...
|
|
|
All times are GMT -5. The time now is 05:17 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|