how to edit grub.cfg to boot win 7?

25,882

You might notice that the grub.cfg file advises not to make changes to that file. To edit grub, make your changes to /etc/default/grub. Then run sudo update-grub. The update-grub will make the permanent changes to your grub.cfg file.

If you are trying to make Windows your Priority Boot device, you can do that by make grub default to saved. This way Grub will remember the last OS you booted to and will boot to that OS until you decide to boot to a different one.

To do this, make these changes to your /etc/default/grub files:

File Edit Options Buffers Tools Conf Help                                                                                                                                   
# If you change this file, run 'update-grub' afterwards to update                                                                                                           
# /boot/grub/grub.cfg.                                                                                                                                                      
# For full documentation of the options in this file, see:                                                                                                                  
#   info -f grub -n 'Simple configuration'                                                                                                                                  

GRUB_DEFAULT="saved"
GRUB_SAVEDEFAULT="true"
#GRUB_HIDDEN_TIMEOUT="0"                                                                                                                                                    
GRUB_HIDDEN_TIMEOUT_QUIET="true"
GRUB_TIMEOUT="15"
GRUB_DISTRIBUTOR="`lsb_release -i -s 2> /dev/null || echo Debian`"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs                                                                                                           
# This works with Linux (no patch required) and with any kernel that obt

The changes from the default is highlighted by bold letters.

Alternatively you can use the GUI application GRUB Customizer. It's available via a the ppa:

$ sudo add-apt-repository ppa:danielrichter2007/grub-customizer
$ sudo apt-get update
$ sudo apt-get install grub-customizer

After installing the PPA you can run it from the Ubuntu Dash search (grub-customizer).

This GUI application allows you to easily perform a number of options that you might not know how to look for such as sorting the order in which the Launchers Appear in the Boot Menu.

Share:
25,882

Related videos on Youtube

larry
Author by

larry

Updated on September 18, 2022

Comments

  • larry
    larry over 1 year

    I can boot win7 when my laptop is on the start menu,by changing "insmod ldm" into "insmod part_msdos" in grub.cfg to boot window 7.

    Before I update the kernel to 4.4.0-42, I can save the change. Now I can't save the file because it is read only.

    Any suggestions?

  • larry
    larry over 7 years
    Some applications were installed on windows. Ubuntu is just for study.
  • Apologician
    Apologician over 7 years
    Thanks for getting back to me. I made a mistake (for the second time this year... I'll be more careful), but I meant for my question to be a comment so that I could get the information so that I could provide the correct details in my answer. I clicked on answer when I meant to click on comment. Anyway, based on your question and comment, I have provided what it appears you are looking for.
  • Apologician
    Apologician over 7 years
    Bob. Changing system files to 777 is a serious security issue. Also some applications will become broken if their files don't have the correct attributes. If he has the access to change the files to make them world accessible, he could use the same access to access the files the with the permission they already have. This way the system files will remain in proper integrity. Just use sudo edit the system configuration files. The particular file he's having problems with shouldn't be manually edited.
  • AtomiX84
    AtomiX84 over 5 years
    I agree with @L.D.James, in case are really necessary modify a RO file you can override the RO option (in vim) by open the file as root then to exit type :wq! this will save the modification also in RO files.