Editing grub.cfg has removed Windows from the boot menu, though Windows is present in grub.cfg file

Asked by Arindam on 2009-12-02

Editing grub.cfg has removed Windows from the boot menu, though Windows is present in grub.cfg file

After editing grub.cfg following the below steps:
1. Windows is not listed in boot menu
2. After logging in unable to access windows drives

Though menu.cfg has Windows listed, why it is not displayed in boot menu?

Followed the steps mentioned at: http://ubuntuforums.org/showthread.php?t=1195275 ("Building a Totally Customized Menu" section)

    * Run sudo update-grub to get the current available kernels.
    * Copy the desired "menuentry" listings from /boot/grub/grub.cfg to /etc/grub.d/40_custom The entry begins with the line starting with "menuentry" and ends with a line containing "}".
    * Add any other "menuentry" items you wish to see on the boot menu.
    * Edit the titles of the "menuentry" line if desired (between the quotation symbols). Do not change the lines following the "menuentry" line. Each entry should start with a "menuentry" line and end with a "}" on the last line.
    * Remove the executable bit from /etc/grub.d/10_linux, /etc/grub.d/20_memtest86+ and /etc/grub.d/30_os-prober
      Removing the executable bit from any file in /etc/grub.d will exclude the file from being included in grub updates.
      Code:

      sudo chmod -x /etc/grub.d/10_linux /etc/grub.d/20_memtest86+ /etc/grub.d/30_os-prober

    * Run "sudo update-grub"
    * The updated /boot/grub/grub.cfg file should now contain only sections for "00_header", "05_debian_theme" and "40_custom".
    * The grub.cfg file will not be updated with the addition of a new kernel. To add a new kernel, make "10_linux" executable, run "sudo update-grub" to refresh the available kernels, and repeat these instructions.

sections of the edited file.

*************40_custom************
==================================
menuentry "Ubuntu, Linux" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
 set quiet=1
 insmod ext2
 set root=(hd0,7)
 search --no-floppy --fs-uuid --set 2f8cf227-7063-4968-ac91-aa934939e335
 linux /boot/vmlinuz-2.6.31-14-generic root=UUID=2f8cf227-7063-4968-ac91-aa934939e335 ro vga=775 quiet splash
 initrd /boot/initrd.img-2.6.31-14-generic
}
menuentry "Ubuntu, Linux (recovery mode)" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
 insmod ext2
 set root=(hd0,7)
 search --no-floppy --fs-uuid --set 2f8cf227-7063-4968-ac91-aa934939e335
 linux /boot/vmlinuz-2.6.31-14-generic root=UUID=2f8cf227-7063-4968-ac91-aa934939e335 ro single vga=775
 initrd /boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Microsoft Windows XP Professional" {
 insmod ntfs
 set root=(hd0,1)
 search --no-floppy --fs-uuid --set e2c0e27ec0e257f5
 drivemap -s (hd0) ${root}
 chainloader +1

***************grub.cfg*****************
========================================
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s /boot/grub/grubenv ]; then
  have_grubenv=true
  load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
  saved_entry=${prev_saved_entry}
  save_env saved_entry
  prev_saved_entry=
  save_env prev_saved_entry
fi
insmod ext2
set root=(hd0,7)
search --no-floppy --fs-uuid --set 2f8cf227-7063-4968-ac91-aa934939e335
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=640x480
  insmod gfxterm
  insmod vbe
  if terminal_output gfxterm ; then true ; else
    # For backward compatibility with versions of terminal.mod that don't
    # understand terminal_output
    terminal gfxterm
  fi
fi
if [ ${recordfail} = 1 ]; then
  set timeout=-1
else
  set timeout=10
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/white
### END /etc/grub.d/05_debian_theme ###

### 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 "Ubuntu, Linux" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
 set quiet=1
 insmod ext2
 set root=(hd0,7)
 search --no-floppy --fs-uuid --set 2f8cf227-7063-4968-ac91-aa934939e335
 linux /boot/vmlinuz-2.6.31-14-generic root=UUID=2f8cf227-7063-4968-ac91-aa934939e335 ro vga=775 quiet splash
 initrd /boot/initrd.img-2.6.31-14-generic
}
menuentry "Ubuntu, Linux (recovery mode)" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
 insmod ext2
 set root=(hd0,7)
 search --no-floppy --fs-uuid --set 2f8cf227-7063-4968-ac91-aa934939e335
 linux /boot/vmlinuz-2.6.31-14-generic root=UUID=2f8cf227-7063-4968-ac91-aa934939e335 ro single vga=775
 initrd /boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Microsoft Windows XP Professional" {
 insmod ntfs
 set root=(hd0,1)
 search --no-floppy --fs-uuid --set e2c0e27ec0e257f5
 drivemap -s (hd0) ${root}
 chainloader +1
### END /etc/grub.d/40_custom ###

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu grub2 Edit question
Assignee:
No assignee Edit question
Solved by:
actionparsnip
Solved:
2009-12-03
Last query:
2009-12-03
Last reply:
2009-12-03

you do NOT edit grub.cfg

grub.cfg is GENERATED so next time you install a new kernel any and all changes WILL be lost

You need to edit the scripts and config files which grub uses to make that file so that the extra boot is permanent between updates

If you want to test simply run:

sudo update-grub

which is ran after a kernel update is installed, your change is no longer there

I suggest you read:
https://help.ubuntu.com/community/Grub2

Arindam (arindam-biswas) said : #2

I have not edited grub.cfg directly. I have followed the steps mentioned in the above link to edit the files under /etc/grub.d folder and then generated latest version of grub.cfg by running update-grub.

wojox (wojox) said : #3

Try a closing bracket ( } ) after chainloader +1

Yours:

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Microsoft Windows XP Professional" {
 insmod ntfs
 set root=(hd0,1)
 search --no-floppy --fs-uuid --set e2c0e27ec0e257f5
 drivemap -s (hd0) ${root}
 chainloader +1

Mine:

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Microsoft Windows XP Professional" {
 insmod ntfs
 set root=(hd0,1)
 search --no-floppy --fs-uuid --set e2c0e27ec0e257f5
 drivemap -s (hd0) ${root}
 chainloader +1
}

Arindam (arindam-biswas) said : #4

:-). You got it right. Thanks a lot!!

Arindam (arindam-biswas) said : #5

Thanks actionparsnip, that solved my question.