Changing the default Boot OS in GRUB on Ubuntu 9.10

Ubuntu 9.10 ships with the new GRUB (Grand Unified Boot Loader 1.97 beta) in plain words its the software that boots the operating system you choose when you boot the computer. In earlier versions of Ubuntu / Grub to change the menu on the grub screen, one had to edit the /boot/grub/menu.lst file. In the new system this a little different from just editing the one file.

The GRUB configuration now resides at /boot/grub/menu.cfg But do not edit this file as it is generated from files from /etc/grub.d/* and /etc/default/grub

Instructions on how to change the default operating system

  1. First be root sudo su
  2. Edit the file /etc/default/grub The contents of the file would be like as shown below : # If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. GRUB_DEFAULT=3 #GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_TIMEOUT=10 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" GRUB_CMDLINE_LINUX="" # Uncomment to disable graphical terminal (grub-pc only) #GRUB_TERMINAL=console # The resolution used on graphical terminal # note that you can use only modes which your graphic card supports via VBE # you can see them in real GRUB with the command `vbeinfo' #GRUB_GFXMODE=640x480 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux #GRUB_DISABLE_LINUX_UUID=true # Uncomment to disable generation of recovery mode menu entrys #GRUB_DISABLE_LINUX_RECOVERY="true"
  3. Change the GRUB_DEFAULT value to number your default operating system Usually
    0 - Linux, 
    1 - Linux, 
    2 and 3 - Memtest, 
    4 - Custom OS (Windows?)
    
    Change GRUB_TIMEOUT to change the default timeout if you want to.
  4. Run update-grub
root@digitalpbk# update-grub Generating grub.cfg ... Found linux image: /boot/vmlinuz-2.6.31-14-generic Found initrd image: /boot/initrd.img-2.6.31-14-generic Found memtest86+ image: /boot/memtest86+.bin Found Microsoft Windows XP Home Edition on /dev/sda1 done

Reboot the system to verify your changes.

Happy Booting ;)

Note: Although I found a built in command grub-set-default, It did not seem to do the job.

On /etc/grub.d Directory you can see many files named in the format XX_...where XX is a 2 digit number. The ones starting with 0 are not listed. Rest is starting from 1X, 2X, 3X etc.

  • 1X_ would be your linux operating system
  • 2X_ would be usually the memtest
  • 3X_ would usually be your other Operating System, (Microsoft Windows? )

Found an easier way ? Please Share :)

08 Nov, 2009
Comments (23)
  • Some Pet Peeves

    Just a couple of things that piss me off-

    1. Making Linux the default boot is arrogant. It's common sense to leave the pre-existing OS as the default boot. This type of arrogance and lack of common sense, is more like Microsoft than Linux.

    2. The instructions are fairly simple, however, for someone not too familiar with Linux they would be a complete bitchh to pull off. For the following reasons-

    a) My /etc/default/grub file was read-only.
    b) I had to chmod it.
    c) Finding the boot order was confusing, because memory tests take up two slots, as well as Linux boots. (Normal and recovery)
    d) To top it all off, I had to fire up the "vi" editor

    3. To 'vi edit the file,' I also had to use Sudo

    To be fair- SUDO is actually a useful tool in certain rare situations, it's just applied badly as a default since 90% of systems don't need it. I can see it having its place on certain mission critical systems, banking servers, life support systems, etc. But even in that case, there are still better ways than Sudo to accomplish keeping a system safe from careless .

    By Anonymous on 09 Jul, 2011
  • Thanks a lot !!

    Thanks digitalpbk. I am coming from howtogeek webpage through the link you posted in the comments section. Now it's working :) and Thanks

    By sai on 03 Jul, 2011
  • Thanks a lot!

    Thanks a lot!

    By Bill on 28 Feb, 2010
  • what if Windows is not #4?

    For me, Windows was #7 in the menu.
    So I could have set GRUB_DEFAULT=7, I guess, but instead I took mscomms's advice and did
    mv 30_os-prober 02_os-prober
    so that *_os-prober would be before any other menu entries.

    However, *_os-prober produced DELL Utility Partition before Windows XP boot partition.
    So I ended up setting GRUB_DEFAULT=1 (instead of 0).
    I think that will work.

    I would also like to get rid of the old linux kernel in my boot menu... but I spose it doesn't really hurt anything.
    It's just a cluttered list.

    By Lars on 29 Jan, 2010
  • Thanks

    I've been searching all over for a simple way to change default OS in grub. This method worked great; thank you very much. I'm still puzzled though. If it ain't broke, why fix it? Menu.lst worked just fine.

    By Allan on 25 Dec, 2009
  • Thanks

    This worked for me.
    Thanks for putting this up.

    By Matt on 22 Dec, 2009
  • Awesome - worked great.

    Awesome - worked great. Thanks for your help.

    By Geno on 26 Nov, 2009
  • Order change on grub menu

    Go to /etc/grub.d
    The scripts in this directory are run in the orer of the first 2 digits so mv 30_os-prober to 09_os-prober it will now run before the 10_linux script and your Windows install will appear first

    By mscomms on 26 Nov, 2009
  • I want my Windows XP to sit

    I want my Windows XP to sit at the top of the Grub menu.
    How do I do this?

    Thanks.

    By Ravin on 21 Nov, 2009
    • Go to /etc/grub.d The scripts

      Go to /etc/grub.d
      The scripts in this directory are run in the orer of the first 2 digits so mv 30_os-prober to 09_os-prober it will now run before the 10_linux script and your Windows install will appear first

      By mscomms on 26 Nov, 2009
  • Can't see Grub file.

    See i have upgraded the the Ubuntu 9.10 from 9.04. And wants to change boot image. But when i put the command # sudo gedit /etc/default/grub After being a Root. then opening a new file.. When i brows that folder then also i am not able to find out that grub file... So will you please suggest me what i need to do?

    By Zia on 17 Nov, 2009
    • Has the GRUB been updated?

      Just make sure your grub has been updated. Try /boot/grub folder , ls it and paste the output ?
      By digitalpbk on 18 Nov, 2009
  • error

    <i>Edit the file /etc/default/grub</i>

    on typing this from terminal am getting the following error message, "/etc/default/grub is not a file or directory"

    By Jam on 12 Nov, 2009
    • Try the command update-grub

      Just run the update-grub command, and post the response ?
      By digitalpbk on 17 Nov, 2009
  • Re:Changing the default Boot OS in GRUB on Ubuntu 9.10

    Hi
    When I do that, I get the following reaction:
    "bash: /etc/default/grub: Permission denied "
    How to handle that. Any idea?

    Thanks

    By memin on 12 Nov, 2009
    • Are you root ?

      Make sure you are the root user before editing the files. If you are using gedit to edit the files, make sure you use the following command : gksudo gedit file
      By digitalpbk on 17 Nov, 2009
      • I tried running sudo su and I

        I tried running sudo su and I get

        root@Erik-PC:/home/erik#
        However when I input the command it also says permission denied.

        Can you help me?

        : /

        By Erik on 15 May, 2010
        • The same thing

          I'm having the same problem... permission denied... any suggestions?

          By Derathor on 31 Aug, 2010
          • Re-Read the article...... you

            Re-Read the article...... you need elevated privilages...... 'sudo su'

            By Anonymous on 01 Nov, 2010
        • ok i've found a solution

          Just enter the command; sudo vi /etc/default/grub and you'll be able to enter the file.

          By Derathor on 31 Aug, 2010
          • Ya that was helpful but i am not able to edit the file.
            Any solutions
            Using ubunto 12.04

            By Prohank on 09 Jul, 2012
        • The final!

          Ok, done!

          First, open the console and enter sudo su, then enter your password in order to get to root mode.

          Type; sudo gedit /etc/default/grub this will open the file grub in the gedit text editor. You can make the changes easily. Remember, the number you need to enter is the number of the row that your windows is on. You must define 0 as the first row as you count. (For me, it was 10) After making the necessary changes save and exit gedit. Then write

          update-grub to the console.

          When its done, exit. This is it. Hope it works for you too.

          By Derathor on 31 Aug, 2010
You may also like
Tags
On Facebook
Email Newsletter