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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
01-10-2010, 01:24 AM
|
#1
|
|
Member
Registered: Sep 2005
Posts: 154
Rep:
|
Grub2 and windows menuentries?
I have been reading this but could not resolve my issue:
http://ubuntuforums.org/showthread.php?t=1195275
The problem is as follows. I got a samsung laptop and there is some kind of recovery utility installed. After installing Ubuntu I get too windows grub entries, one is called Windows Vista (loader) on /dev/sda1 and the other one is Windows 7 (loader) on /dev/sda2. The latter is correct and the first one is something that I'd rather not have active at all in the grub menu. Both of them are of course created by 30_os-prober in /etc/grub.d.
I figured that I would most likely prefer a custom entry for Windows 7 and remove the x flag from 30_os-prober. I tried to create a file 50_windows7 in a described manner:
#! /bin/sh -e
echo "Adding Windows 43_custom" >&2
menuentry "Windows Vista 43_custom" {
insmod ntfs
set root=(hd0,2)
search --no-floppy --fs-uuid --set 7cecddfbecddb01e
chainloader +1
}
Unfortunately during update-grub I get following:
Found linux image: /boot/vmlinuz-2.6.31-17-generic
Found initrd image: /boot/initrd.img-2.6.31-17-generic
Found linux image: /boot/vmlinuz-2.6.31-14-generic
Found initrd image: /boot/initrd.img-2.6.31-14-generic
Found Windows Vista (loader) on /dev/sda1
Found Windows 7 (loader) on /dev/sda2
Adding Windows 43_custom
/etc/grub.d/50_windows7: 4: menuentry: not found
So beats me - where do I go wrong?
|
|
|
|
01-10-2010, 05:31 AM
|
#2
|
|
Guru
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,002
|
My "Custom menu: looks like this:
Code:
#! /bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "GPS_Linux" {
set root=(hd1,2)
linux /boot/vmlinuz-2.6.31-16 root=/dev/sdb2 ro
initrd /boot/initrd.img-2.6.31-16
}
It works, but I still hate grub2
|
|
|
|
01-10-2010, 08:14 AM
|
#3
|
|
Member
Registered: Sep 2005
Posts: 154
Original Poster
Rep:
|
I tried to insert that in 50_custom file as well:
$ cat 40_custom
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Windows 7" {
insmod ntfs
set root=(hd0,2)
search --no-floppy --fs-uuid --set 7cecddfbecddb01e
chainloader +1
}
It even creates the entry in the end of grub.cfg:
menuentry "Windows 7 (loader) (on /dev/sda2)" {
insmod ntfs
set root=(hd0,2)
search --no-floppy --fs-uuid --set 7cecddfbecddb01e
chainloader +1
}
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Windows 7" {
insmod ntfs
set root=(hd0,2)
search --no-floppy --fs-uuid --set 7cecddfbecddb01e
chainloader +1
}
### END /etc/grub.d/40_custom ###
I can see no difference to the previous one generated by 30_os-prober
but still the last option will not appear in reboot 
|
|
|
|
01-10-2010, 09:27 AM
|
#4
|
|
Guru
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,002
|
I am confused now.
You did not want to see "Windows Vista (loader) on /dev/sda1" in your grub menu.
So the plan was to chmod -x 30_os-prober to stop that bit working, and write your own custom
menu entry for "Windows 7 on /dev/sda2"
So you wrote your custom menu, but it failed with
"/etc/grub.d/50_windows7: 4: menuentry: not found"
Now you have re-written your custom menu (with the "exec tail" line included now)
And it is creating this entry in /boot/grub/grub.cfg
Code:
### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Windows 7" {
insmod ntfs
set root=(hd0,2)
search --no-floppy --fs-uuid --set 7cecddfbecddb01e
chainloader +1
}
### END /etc/grub.d/40_custom ###
Which looks OK.
( 30_os-prober is still running, I notice. )
But then you say
Quote:
I can see no difference to the previous one generated by 30_os-prober
but still the last option will not appear in reboot.
|
Do you mean that grub is not offering you an entry that says "Windows 7" ?
|
|
|
|
01-10-2010, 12:00 PM
|
#5
|
|
Member
Registered: Sep 2005
Posts: 154
Original Poster
Rep:
|
Quote:
Originally Posted by tredegar
Do you mean that grub is not offering you an entry that says "Windows 7" ?
|
Yes, that is what I am saying, although it is added to the end of the /boot/grub/grub.cfg after I run sudo update-grub2 command.
What I initially tried was creating a new file 50_windows7 under /etc/grub.d/ but it did not seem to work that well therefore I modified the existing file 40_custom according to your example and it works so far that it adds the entry to the grub.cfg, although during update-grub2 it says nothing about the entry "Windows 7":
$ sudo update-grub2
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.31-17-generic
Found initrd image: /boot/initrd.img-2.6.31-17-generic
Found linux image: /boot/vmlinuz-2.6.31-14-generic
Found initrd image: /boot/initrd.img-2.6.31-14-generic
Found Windows Vista (loader) on /dev/sda1
Found Windows 7 (loader) on /dev/sda2
done
the last two entries for windows here are from 30_os-prober file, I also tried disabling it (chmod -x) with the effect of not having any windows entry whatsoever. Of course I could manually edit grub.cfg and remove the Vista lines but generally that should be no-no...
|
|
|
|
01-10-2010, 12:12 PM
|
#6
|
|
Guru
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,002
|
Quote:
|
Yes, that is what I am saying, although it is added to the end of the /boot/grub/grub.cfg after I run sudo update-grub2 command.
|
Are you sure you have only one /boot directory in all your partitions?
I have several /boot partitions, and need to be sure I am using the right one when I update-grub, as otherwise, although /boot/grub/grub.cnf gets updated, it's the wrong one, and grub never looks for it (it is looking at another partition for the cnf file, and that is unchanged).
Quote:
|
the last two entries for windows here are from 30_os-prober file, I also tried disabling it (chmod -x) with the effect of not having any windows entry whatsoever.
|
That implies that your custom script is not being run. Have you chmod +x'd it?
Might be a good idea to make your custom menu entry obviously different from the auto-generated ones: "###Window 7###" to avoid confusion.
I have update-grub and update-grub2 but I have always used update-grub
[Off - topic: Above, it says "Originally Posted by tredegar > " and there's a little blue thing pointing to my post. How did you do that? ]
|
|
|
|
01-10-2010, 12:34 PM
|
#7
|
|
Member
Registered: Sep 2005
Posts: 154
Original Poster
Rep:
|
I googled some more with 40_custom and found out that my problem was not unique. Guess what the problem was... In the end of my 40_custom I had a space character after the closing bracket }
After I deleted the trailing empty space it worked ok.
So in the end it was grub2 ditching the last entry in grub.cfg due to that space - now it works as I wanted
|
|
|
|
01-10-2010, 12:51 PM
|
#8
|
|
Guru
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,002
|
Quote:
|
After I deleted the trailing empty space it worked ok.
|
Hmmmm, a trailing space: No error message, no error-handling, no warning, just fall over and die.
Another reason why grub2 isn't yet fit for release. I hate it.
But another good reason to post code in CODE tags though, as someone might have picked that up.
Pleased your system is bootable again though.
|
|
|
|
01-10-2010, 01:29 PM
|
#9
|
|
Member
Registered: Sep 2005
Posts: 154
Original Poster
Rep:
|
Quote:
Originally Posted by tredegar
Another reason why grub2 isn't yet fit for release. I hate it.
|
Yes, Ubuntu 9.10 and some features like grub2 is giving me some unpleasant mandriva flashbacks too
Quote:
|
Pleased your system is bootable again though.
|
Yes, it was bootable all along, only that one Vista boot option
could have been dangerous in my wife's hands 
|
|
|
|
01-10-2010, 01:48 PM
|
#10
|
|
Guru
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,002
|
I understand.
But outstanding, from post #6:
[Off - topic: Above, it says "Originally Posted by tredegar > " and there's a little blue thing pointing to my post. How did you do that? ]
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
|
Altering GRUB2
|
toomuchespresso |
Linux - Newbie |
4 |
01-03-2010 10:07 AM |
|
grub vs grub2
|
miros84 |
Linux - Software |
5 |
01-03-2010 05:41 AM |
|
Grub2 in my own distribution
|
artal |
Linux - Distributions |
15 |
12-19-2009 08:02 AM |
|
grub2
|
mbvo |
Slackware |
7 |
11-12-2009 06:06 AM |
|
Editing GRUB2
|
ssinustwo |
Fedora - Installation |
1 |
07-20-2004 09:16 PM |
All times are GMT -5. The time now is 01:45 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
|
|