Modifying GRUB2
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Modifying GRUB2
I get entries for Win7 and Vista on the boot menu. Does anyone know how to remove the Vista entry?
Harry Webb
Harry Webb
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.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Modifying GRUB2
Is Vista still installed, if so you're better off with it in there, if not open a terminal and type "sudo update-grub" this should research the drives and only find installations on partitions.
Re: Modifying GRUB2
I would not feel comfortable helping someone with this but here's a good thread on the subject.
http://ubuntuforums.org/showthread.php?t=1287602
http://ubuntuforums.org/showthread.php?t=1287602
Re: Modifying GRUB2
I have an HP Pavilion and this appears to be the recovery partition of the HD. I've no idea why it's labelled 'Vista', however I don't want casual users to try to load it.
Harry
Harry
Re: Modifying GRUB2
Excellent guide with screen shots: http://www.dedoimedo.com/computers/grub-2.html
A wealth of information: https://help.ubuntu.com/community/Grub2
If you still have trouble, let me know.
A wealth of information: https://help.ubuntu.com/community/Grub2
If you still have trouble, let me know.
Re: Modifying GRUB2
You have shown me where to find a very useful guide to Grub2. I have used an earlier version to change the menu colour and to eliminate 'Recovery Mode' and Memtest from the boot menu. However I can't find the option to remove other OS entries which was easily done in menu.lst. Any suggestions would be welcome.
Harry
Harry
Re: Modifying GRUB2
The correct answer to that question is 'no' . Nobody does know how to remove it. This is one of the biggest problems with grub2, if it automatically reads something as being there on your disk then you can run update-grub until you keyboard wears out, it will never go away. I have exactly the same problem - grub2 insists that I have 2 versions of Windows on my machine. Nothing will convince it otherwise. Why not? Because it is not good enough to use as a default boot manager in its present form, that is why not, and it should not have been used by Ubuntu or anyone else until it is good enough.Harry Webb wrote:I get entries for Win7 and Vista on the boot menu. Does anyone know how to remove the Vista entry?
Harry Webb
You can get rid of the entry temporarily. Either by altering /etc/grub.cfg directly (which is what I do and by far the easiest way, but you will have to make the file writeable first) or by copying the entries you do want to have in view from /etc/grub.cfg to /etc/grub.d/40_custom then by removing the executable bit from etc/grub.d/30_os-prober. Then running
Code: Select all
sudo update-grub
This is why the people that wrote grub2 ought to be taken out and shot whilst the people that defend it ought to be taken out and horse whipped
Re: Modifying GRUB2
It might be possible, although I'm not sure if the following instructions will work - I may not understand fully what goes on. I'd try it myself, but I don't use grub2.viking777 wrote:The correct answer to that question is 'no' . Nobody does know how to remove it.
Please backup the file being used before attempting
Here is how to backup easily to your home directory and restore in case you do not know.
Code: Select all
To Backup
sudo cp /etc/grub.d/30_os-prober ~/30_os-prober.backup
Code: Select all
To Restore
sudo mv ~/30_os-prober.backup /etc/grub.d/30_os-prober
2. /etc/grub.d/30_os-prober - Changing Windows or Other Detected OS Titles (including Linux)
You need to edit this file, with terminal
Code: Select all
gksudo gedit /etc/grub.d/30_os-prober
Code: Select all
sudo cat /boot/grub/grub.cfg | grep "menuentry" | cut -d '"' -f 2
Code: Select all
# Original
# if [ -z "${LONGNAME}" ] ; then
# LONGNAME="${LABEL}"
# fi
if [ "${LONGNAME}" = "Enter The Title of the Menu Entry you want to keep from the command you used above" ] ; then
LONGNAME="${LABEL}"
fi
Code: Select all
sudo update-grub
If it doesn't work, replace the original file with the backup file, and run "sudo update-grub" again.
Post back if you do not understand a step / it didn't work / it worked.
Re: Modifying GRUB2
One other solution, which might seem a bit drastic, would be to delete the SYTEM_IMAGE partition. I have made copies already and tucked them safely away. I'm not sure what happens if somebody selects the 'Vista' option - would it proceed to reformat the entire disk and replace the original Win7/HP set-up? This would not be the end of the world but would involve many hours of work to get back to where I am now. While I quite like the look of Win7, I already find that I am turning to Linux to do most things.
Harry
Harry
Re: Modifying GRUB2
Nonsense, you just answered it yourself. It is very easy once you get the hang of it. I understand change is hard, but the grub legacy also has update-grub, but it is not as full featured. I think the reason they did it this way is for a more robust os prober routine. Here is what you do, copy and paste the menu entries that you want to keep from grub.cfg to lets say 40_custom. So, say OS_prober worked correctly for Mint, and you want to keep a menu entry for it, but get rid of Vista, just list the contents of your grub.cfg:viking777 wrote:The correct answer to that question is 'no' . Nobody does know how to remove it. This is one of the biggest problems with grub2, if it automatically reads something as being there on your disk then you can run update-grub until you keyboard wears out, it will never go away. I have exactly the same problem - grub2 insists that I have 2 versions of Windows on my machine. Nothing will convince it otherwise. Why not? Because it is not good enough to use as a default boot manager in its present form, that is why not, and it should not have been used by Ubuntu or anyone else until it is good enough.Harry Webb wrote:I get entries for Win7 and Vista on the boot menu. Does anyone know how to remove the Vista entry?
Harry Webb
You can get rid of the entry temporarily. Either by altering /etc/grub.cfg directly (which is what I do and by far the easiest way, but you will have to make the file writeable first) or by copying the entries you do want to have in view from /etc/grub.cfg to /etc/grub.d/40_custom then by removing the executable bit from etc/grub.d/30_os-prober. Then runningBut if you do the latter then any other distros that you might install in the future will not show up either.Code: Select all
sudo update-grub
This is why the people that wrote grub2 ought to be taken out and shot whilst the people that defend it ought to be taken out and horse whipped
Code: Select all
cat /boot/grub/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/update-grub using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
set default=0
set timeout=20
set root=(hd2,5)
search --fs-uuid --set 9b26a82d-9011-40ea-b97c-3deb4b0f9ee8
if font /share/grub/ascii.pff ; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
terminal gfxterm
fi
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=green/black
set menu_color_highlight=white/green
### END /etc/grub.d/05_debian_theme ###
### BEGIN /etc/grub.d/12_Gloria ###
menuentry "Linux Mint Gloria XFCE" {
set root=(hd2,1)
linux /vmlinuz-2.6.28-11-generic root=/dev/sdc2 ro quiet splash
initrd /initrd.img-2.6.28-11-generic
}
### END /etc/grub.d/12_Gloria ###
### BEGIN /etc/grub.d/13_Helena ###
search --no-floppy --fs-uuid --set 3a288d4b-d615-4ee6-bdc4-0d680971aebf
menuentry "Linux Mint 8 Helena" {
set root=(hd3,2)
linux /boot/vmlinuz-2.6.31-14-generic root=UUID=3a288d4b-d615-4ee6-bdc4-0d680971aebf ro quiet splash
initrd /boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/13_Helena ###
### BEGIN /etc/grub.d/14_OpenBSD ###
set root=(hd3,1)
### search --no-floppy --fs-uuid --set c769b531-abc6-42cf-82d4-cdbe57bc2b41
menuentry "OpenBSD 4.6" {
chainloader +1
}
### END /etc/grub.d/14_OpenBSD ###
### BEGIN /etc/grub.d/18_WinXP ###
menuentry "WinXP64" {
set root=(hd0,1)
chainloader +1
}
### END /etc/grub.d/18_WinXP ###
### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows Vista (loader) (on /dev/sda1)" {
set root=(hd0,1)
chainloader +1
}
menuentry "Linux Mint 8 Helena - Main Edition (8) (on /dev/sdd2)" {
set root=(hd3,2)
linux /boot/vmlinuz-2.6.31-14-generic root=/dev/sdd2
initrd /boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/30_os-prober ###
Then just copy and paste the entry from 30_os-prober you want to keep into a new file that starts with a number and an underscore.
For example, you can copy and paste just this part:
Code: Select all
menuentry "Linux Mint 8 Helena - Main Edition (8) (on /dev/sdd2)" {
set root=(hd3,2)
linux /boot/vmlinuz-2.6.31-14-generic root=/dev/sdd2
initrd /boot/initrd.img-2.6.31-14-generic
}
Code: Select all
#!/bin/sh -e
cat << EOF
Code: Select all
EOF
As you can see (from my /boot/grub/grub.cfg file), I have several small custom scripts; /etc/grub.d/12_Gloria, /etc/grub.d/13_Helena, /etc/grub.d/14_OpenBSD, and /etc/grub.d/18_WinXP. The upddate-grub script will call each script in numerical order, so I just named them according to where I wanted them on my menu entry list.
Now, the /etc/grub.d/30_os-prober is of course the script that auto detects your installed systems. If it works correctly it is great because it can help noobs find their newly installed OS without having to make a custom entry from scratch.
So this part:
Code: Select all
### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows Vista (loader) (on /dev/sda1)" {
set root=(hd0,1)
chainloader +1
}
menuentry "Linux Mint 8 Helena - Main Edition (8) (on /dev/sdd2)" {
set root=(hd3,2)
linux /boot/vmlinuz-2.6.31-14-generic root=/dev/sdd2
initrd /boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/30_os-prober ###
For reference, here are my scripts found in /etc/grub.d
Code: Select all
Lamiaceae grub.d # ll
total 84
-rwxr-xr-x 1 root root 1897 2009-02-25 10:42 00_header
-rwxr-xr-x 1 root root 1149 2009-12-23 23:06 05_debian_theme
-rw-r--r-- 1 root root 2212 2009-02-25 10:42 10_hurd
-rw-r--r-- 1 root root 3877 2009-02-25 10:42 10_linux
-rwxr-xr-x 1 root root 188 2009-12-28 23:37 12_Gloria
-rwxr-xr-x 1 root root 300 2009-12-23 23:26 13_Helena
-rwxr-xr-x 1 root root 165 2009-12-28 23:56 14_OpenBSD
-rw-r--r-- 1 root root 1105 2009-12-23 23:30 15_Gloria_cases
-rw-r--r-- 1 root root 544 2009-12-28 20:25 16_test
-rw-r--r-- 1 root root 149 2009-12-28 01:49 17_testXP
-rwxr-xr-x 1 root root 177 2009-12-28 23:51 18_WinXP
-rw-r--r-- 1 root root 407 2009-03-27 10:15 20_memtest86+
-rw-r--r-- 1 root root 218 2009-12-23 21:54 22_fail
-rwxr-xr-x 1 root root 2567 2009-02-25 10:42 30_os-prober
-rwxr-xr-x 1 root root 852 2010-01-15 19:23 32_iso
-rw-r--r-- 1 root root 84 2009-02-25 10:42 40_custom
-rwxr-xr-x 1 root root 275 2010-01-14 22:46 40_multiboot
Now that I have my custom entries made, and made them executable, I just remove the executable bit from 30_os-prober
Code: Select all
sudo chmod -x 30_os-prober
Now look at the long listing of ls:
Code: Select all
ls -l
Code: Select all
-rw-r--r-- 1 root root 2567 2009-02-25 10:42 30_os-prober
Code: Select all
sudo update-grub
Output of grub.cfg:
Code: Select all
cat /boot/grub/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/update-grub using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
set default=0
set timeout=20
set root=(hd2,5)
search --fs-uuid --set 9b26a82d-9011-40ea-b97c-3deb4b0f9ee8
if font /share/grub/ascii.pff ; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
terminal gfxterm
fi
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=green/black
set menu_color_highlight=white/green
### END /etc/grub.d/05_debian_theme ###
### BEGIN /etc/grub.d/12_Gloria ###
menuentry "Linux Mint Gloria XFCE" {
set root=(hd2,1)
linux /vmlinuz-2.6.28-11-generic root=/dev/sdc2 ro quiet splash
initrd /initrd.img-2.6.28-11-generic
}
### END /etc/grub.d/12_Gloria ###
### BEGIN /etc/grub.d/13_Helena ###
search --no-floppy --fs-uuid --set 3a288d4b-d615-4ee6-bdc4-0d680971aebf
menuentry "Linux Mint 8 Helena" {
set root=(hd3,2)
linux /boot/vmlinuz-2.6.31-14-generic root=UUID=3a288d4b-d615-4ee6-bdc4-0d680971aebf ro quiet splash
initrd /boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/13_Helena ###
### BEGIN /etc/grub.d/14_OpenBSD ###
set root=(hd3,1)
### search --no-floppy --fs-uuid --set c769b531-abc6-42cf-82d4-cdbe57bc2b41
menuentry "OpenBSD 4.6" {
chainloader +1
}
### END /etc/grub.d/14_OpenBSD ###
### BEGIN /etc/grub.d/18_WinXP ###
Adding Win XP to grub2 menu
### search --no-floppy --fs-uuid --set 06e4a1eae4a1dbe5
menuentry "WinXP64" {
set root=(hd0,1)
chainloader +1
}
### END /etc/grub.d/18_WinXP ###
Yes if you install a new OS you will want to make os-prober executable again and run update-grub but once you do that just do a real quick copy and paste, even in gedit or mousepad, put it into your own script, change os-prober to NOT be executable, then re-run update-grub. BUT if you are good, you don't need os-prober, just write it by hand in the first place!
Here are some the actual scripts I use, and that are execuatable (of course they are in /etc/grub.d)
Mint 7 Gloria XFCE, file name 12_Gloria
Code: Select all
#!/bin/sh -e
cat << EOF
menuentry "Linux Mint Gloria XFCE" {
set root=(hd2,1)
linux /vmlinuz-2.6.28-11-generic root=/dev/sdc2 ro quiet splash
initrd /initrd.img-2.6.28-11-generic
}
EOF
Code: Select all
#!/bin/sh -e
cat << EOF
search --no-floppy --fs-uuid --set 3a288d4b-d615-4ee6-bdc4-0d680971aebf
menuentry "Linux Mint 8 Helena" {
set root=(hd3,2)
linux /boot/vmlinuz-2.6.31-14-generic root=UUID=3a288d4b-d615-4ee6-bdc4-0d680971aebf ro quiet splash
initrd /boot/initrd.img-2.6.31-14-generic
}
EOF
Code: Select all
#!/bin/sh -e
cat << EOF
menuentry "WinXP64" {
set root=(hd0,1)
chainloader +1
}
EOF
What if I no longer have Helena? (MY grub2 is in Gloria, I added it). Yes, bingo turn of the executable bit.
I also turned off the executable bit for 10_linux, and 20_memtest86+ since I have my Linux entries squared away and I don't want memtest right now.
There is no need to make backups of files nor rename files put in there originally by the grub-pc (grub2) package! Just leave them alone, create your own, then change the executable bits as needed!!!!!
Too verbose? It is quicker than it looks, takes just a minute to do all of this...
Re: Modifying GRUB2
Thank you, Breaker. Unfortunately I don't have your expertise so I'll have to study this for a time before I venture in. There must be hundreds of others with the HP Pavilion who have the same problem that I have. In the past I thought that altering menu.lst was quite daring but in time it became easy. Maybe what you suggest will become familiar in time too. But i can't help thinking that having one central file similar to menu.lst would be quite helpful.
Harry
Harry
Re: Modifying GRUB2
You see this is exactly my point - I am not surprised that Harry won't do it because neither would I (at least not the way it is supposed to be done), and I probably know a bit more about it than Harry does.Harry Webb wrote:Thank you, Breaker. Unfortunately I don't have your expertise so I'll have to study this for a time before I venture in. There must be hundreds of others with the HP Pavilion who have the same problem that I have. In the past I thought that altering menu.lst was quite daring but in time it became easy. Maybe what you suggest will become familiar in time too. But i can't help thinking that having one central file similar to menu.lst would be quite helpful.
Harry
God knows grub legacy was not all that good, but its replacement is even worse!
This program is damaging Linux and that annoys me. I am not saying it can't be sorted out but that is going to take a lot more work, it is not suitable for mainstream use in its present form.
And Harry - all you have to do to get around this nonsense is to make /etc/grub.cfg writeable, it then behaves exactly the same as menu.lst which apparently you are used to using. The only downside to this is that if you ever update your kernel all your changes will be overwritten including the fact that you made grub.cfg writeable in the first place.
Re: Modifying GRUB2
I'm not saying that I won't adopt Breaker's suggestion - just that i want to get a better feel for what I am doing before I do it! Perhaps if anybody has the ear of the authorities on Grub2, the point of this thread could be put to them.
Harry
Harry
Re: Modifying GRUB2
I do see everyone's point of view. I too originally thought it was strange and difficult to modify grub legacy's menu.lst.
However, you are quite correct. If you know what you are doing, you can just modify grub.cfg. The key here is if you never have to use update-grub, you can modify the file directly. In fact, you can just make a really really simple grub.cfg from scratch and just use it, just like menu.lst. This is what I do for my multiboot iso from usb experimnents. Don't get caught up in the details of this grub.cfg, but see just how simple it can be (if you don't need update-grub):
That's all you need, and regular (non-loopback) entries work fine too.
If you want to "play by the grub2 rules" you can just put these all in 40_custom, and make every other script in /etc/grub.d not executable.
Anyway, like I said, I don't see what is so hard, both menu.lst and grub.cfg are cryptic and do the same thing basically, the grub.cfg is just modified through several files, most of which you never have to touch.
I still think it is about change being hard because I am better at grub2 than legacy at this point.
peace..
However, you are quite correct. If you know what you are doing, you can just modify grub.cfg. The key here is if you never have to use update-grub, you can modify the file directly. In fact, you can just make a really really simple grub.cfg from scratch and just use it, just like menu.lst. This is what I do for my multiboot iso from usb experimnents. Don't get caught up in the details of this grub.cfg, but see just how simple it can be (if you don't need update-grub):
Code: Select all
menuentry "Linux Mint Gloria XFCE CE" {
loopback loop /boot/iso/LinuxMint-7-XFCE.iso
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/LinuxMint-7-XFCE.iso noeject noprompt --
initrd (loop)/casper/initrd.gz
}
menuentry "Linux Mint Helena" {
loopback loop /boot/iso/LinuxMint-8.iso
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/LinuxMint-8.iso noeject noprompt --
initrd (loop)/casper/initrd.lz
}
menuentry "Linux Mint Helena 64bit" {
loopback loop /boot/iso/LinuxMint-8-x64.iso
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/LinuxMint-8-x64.iso noeject noprompt --
initrd (loop)/casper/initrd.lz
}
menuentry "Memory test (memtest86+)" {
linux /boot/iso/memtest86+.bin
}
If you want to "play by the grub2 rules" you can just put these all in 40_custom, and make every other script in /etc/grub.d not executable.
Anyway, like I said, I don't see what is so hard, both menu.lst and grub.cfg are cryptic and do the same thing basically, the grub.cfg is just modified through several files, most of which you never have to touch.
I still think it is about change being hard because I am better at grub2 than legacy at this point.
peace..
Re: Modifying GRUB2
I am beginning, slowly, to grasp Grub2, however I am going to proceed cautiously. It seems that if I make 30_os-prober non-executable I will only get Helena in the boot menu. (if there were no menu entries I could recover using the Live CD) If works out then I can put the Windows 7 entry in 40_custom and lose the annoying Vista entry. I think this is what Breaker is saying.
Harry
Harry
Re: Modifying GRUB2
Absolutely Harry, but by making 30_os-prober non-executable you will cause something else to happen as well which may or may not be important to you - it is exceedingly important to me which is why I won't do it. Once you make 30_os-prober non-executable you have effectively ended the ability of your grub loader to detect any other operating system that you might care to install on another partition. Not only that but if you already have an operating system installed on another partition then any changes to that OS (such as a kernel upgrade) will not be detected either.Harry Webb wrote:I am beginning, slowly, to grasp Grub2, however I am going to proceed cautiously. It seems that if I make 30_os-prober non-executable I will only get Helena in the boot menu. (if there were no menu entries I could recover using the Live CD) If works out then I can put the Windows 7 entry in 40_custom and lose the annoying Vista entry. I think this is what Breaker is saying.
Harry
If that doesn't matter to you then you are home and dry, but it does matter to me and once again it is yet another reason that I rate this particular piece of software as an ill thought out piece of junk.
Re: Modifying GRUB2
Good point, Viking. The only other OS I want available at the moment is Win7, so it may not be important. Another possibility is to change the name of the file or folder in the Image Storage partition and restore it using Live CD in the event that I need to restore. Unfortunately I'm not sure what OS-prober looks for when finding the other OS's. Can anyone give me a clue here?
Harry
Harry
Re: Modifying GRUB2
With GRUB2 , every time an update-grub is done, any Microsoft back up partition is also detected and listed on the bootloader menu.
The file /boot/grub/grub.cfg can be edited , with care.
In terminal ,
cd /boot/grub
sudo chmod u+w grub.cfg
This makes the file grub.cfg writable.
sudo nano grub.cfg
Here in NANO you can edit the file. If you want to hide a 'menuentry' place a ' # ' before the word
#menuentry "Windows Vista (loader) (on /dev/sda3)" {
insmod ntfs
set root=(hd0,3)
search --no-floppy --fs-uuid --set 2c88743c8874071c
chainloader +1
}
Then save your changes -- Ctrl/o , enter , Ctrl//x
You can do other editing of the file in this manner.
The file /boot/grub/grub.cfg can be edited , with care.
In terminal ,
cd /boot/grub
sudo chmod u+w grub.cfg
This makes the file grub.cfg writable.
sudo nano grub.cfg
Here in NANO you can edit the file. If you want to hide a 'menuentry' place a ' # ' before the word
#menuentry "Windows Vista (loader) (on /dev/sda3)" {
insmod ntfs
set root=(hd0,3)
search --no-floppy --fs-uuid --set 2c88743c8874071c
chainloader +1
}
Then save your changes -- Ctrl/o , enter , Ctrl//x
You can do other editing of the file in this manner.
Re: Modifying GRUB2
StantheMan is absolutely correct, but don't ever try and use Nano it sucks (nothing against nano in particular, all command line text editors suck).
Will make life far easier if that is the way you want to go.
You have to be using the Gnome version of Mint for that though. For kde change the word gedit to kwrite and for Xfce change it to mousepad.
Code: Select all
sudo gedit /etc/grub.cfg
You have to be using the Gnome version of Mint for that though. For kde change the word gedit to kwrite and for Xfce change it to mousepad.