LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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

Reply
 
Search this Thread
Old 01-10-2010, 01:24 AM   #1
Jykke
Member
 
Registered: Sep 2005
Posts: 166

Rep: Reputation: 16
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?
 
Old 01-10-2010, 05:31 AM   #2
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,008

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
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
 
Old 01-10-2010, 08:14 AM   #3
Jykke
Member
 
Registered: Sep 2005
Posts: 166

Original Poster
Rep: Reputation: 16
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
 
Old 01-10-2010, 09:27 AM   #4
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,008

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
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" ?
 
Old 01-10-2010, 12:00 PM   #5
Jykke
Member
 
Registered: Sep 2005
Posts: 166

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by tredegar View Post

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...
 
Old 01-10-2010, 12:12 PM   #6
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,008

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
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? ]
 
Old 01-10-2010, 12:34 PM   #7
Jykke
Member
 
Registered: Sep 2005
Posts: 166

Original Poster
Rep: Reputation: 16
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
 
Old 01-10-2010, 12:51 PM   #8
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,008

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
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.
 
Old 01-10-2010, 01:29 PM   #9
Jykke
Member
 
Registered: Sep 2005
Posts: 166

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by tredegar View Post

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
 
Old 01-10-2010, 01:48 PM   #10
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,008

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
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? ]
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
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 06:22 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration