For Windows and Linux systems, set the default startup Item

Source: Internet
Author: User

Enter sudo gedit/boot/GRUB/grub. cfg in the terminal.

Install Windows first and then Linux. By default, there will be many startup items. After executing the above command, a document will be opened with the following code:

Trim (I added these dashes myself)

#
# 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 $ prefix/grubenv]; then
Load_env
Fi
Set default = "8"
If [$ {prev_saved_entry}]; then
Set saved_entry =$ {prev_saved_entry}
Save_env saved_entry
Set prev_saved_entry =
Save_env prev_saved_entry
Set boot_once = true
Fi

Function savedefault {
If [-Z $ {boot_once}]; then
Saved_entry =$ {chosen}
Save_env saved_entry
Fi
}

Function recordfail {
Set recordfail = 1
If [-N $ {have_grubenv}]; then if [-Z $ {boot_once}]; then save_env recordfail; FI
}
Insmod ext2
Set root = '(hd0, 9 )'
Search -- no-floppy -- FS-UUID -- set fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f
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
Insmod ext2
Set root = '(hd0, 9 )'
Search -- no-floppy -- FS-UUID -- set fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f
Set locale_dir = ($ root)/boot/GRUB/locale
Set lang = ZH
Insmod gettext
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/light-gray
### End/etc/grub. d/05_debian_theme ###

### Begin/etc/grub. d/10_linux ###
Menuentry 'ubuntu, with Linux 2.6.32-31-generic '-- class Ubuntu -- class GNU-Linux -- class GNU -- class OS {
Recordfail
Insmod ext2
Set root = '(hd0, 9 )'
Search -- no-floppy -- FS-UUID -- set fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f
Linux/boot/vmlinuz-2.6.32-31-generic root = UUID = fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f Ro quiet splash
Initrd/boot/initrd. img-2.6.32-31-generic
}
Menuentry 'ubuntu, with Linux 2.6.32-31-generic (recovery mode) '-- class Ubuntu -- class GNU-Linux -- class GNU -- class OS {
Recordfail
Insmod ext2
Set root = '(hd0, 9 )'
Search -- no-floppy -- FS-UUID -- set fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f
Echo 'loading Linux 2.6.32-31-generic ...'
Linux/boot/vmlinuz-2.6.32-31-generic root = UUID = fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f Ro single

Echo 'loading initial ramdisk ...'
Initrd/boot/initrd. img-2.6.32-31-generic
}
Menuentry 'ubuntu, with Linux 2.6.32-30-generic '-- class Ubuntu -- class GNU-Linux -- class GNU -- class OS {
Recordfail
Insmod ext2
Set root = '(hd0, 9 )'
Search -- no-floppy -- FS-UUID -- set fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f
Linux/boot/vmlinuz-2.6.32-30-generic root = UUID = fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f Ro quiet splash
Initrd/boot/initrd. img-2.6.32-30-generic
}
Menuentry 'ubuntu, with Linux 2.6.32-30-generic (recovery mode) '-- class Ubuntu -- class GNU-Linux -- class GNU -- class OS {
Recordfail
Insmod ext2
Set root = '(hd0, 9 )'
Search -- no-floppy -- FS-UUID -- set fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f
Echo 'loading Linux 2.6.32-30-generic ...'
Linux/boot/vmlinuz-2.6.32-30-generic root = UUID = fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f Ro single

Echo 'loading initial ramdisk ...'
Initrd/boot/initrd. img-2.6.32-30-generic
}
Menuentry 'ubuntu, with Linux 2.6.32-24-generic '-- class Ubuntu -- class GNU-Linux -- class GNU -- class OS {
Recordfail
Insmod ext2
Set root = '(hd0, 9 )'
Search -- no-floppy -- FS-UUID -- set fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f
Linux/boot/vmlinuz-2.6.32-24-generic root = UUID = fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f Ro quiet splash
Initrd/boot/initrd. img-2.6.32-24-generic
}
Menuentry 'ubuntu, with Linux 2.6.32-24-generic (recovery mode) '-- class Ubuntu -- class GNU-Linux -- class GNU -- class OS {
Recordfail
Insmod ext2
Set root = '(hd0, 9 )'
Search -- no-floppy -- FS-UUID -- set fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f
Echo 'loading Linux 2.6.32-24-generic ...'
Linux/boot/vmlinuz-2.6.32-24-generic root = UUID = fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f Ro single

Echo 'loading initial ramdisk ...'
Initrd/boot/initrd. img-2.6.32-24-generic
}
### End/etc/grub. d/10_linux ###

### Begin/etc/grub. d/20_memtest86 + ###
Menuentry "Memory Test (memtest86 + )"{
Insmod ext2
Set root = '(hd0, 9 )'
Search -- no-floppy -- FS-UUID -- set fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f
Linux16/boot/memtest86 +. Bin
}
Menuentry "Memory Test (memtest86 +, serial console 115200 )"{
Insmod ext2
Set root = '(hd0, 9 )'
Search -- no-floppy -- FS-UUID -- set fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f
Linux16/boot/memtest86 +. Bin console = ttys0, 115200n8
}
### End/etc/grub. d/20_memtest86 + ###

### Begin/etc/grub. d/30_os-prober ###
Menuentry "Windows 7 (loader) (on/dev/sda1 )"{
Insmod NTFS
Set root = '(hd0, 1 )'
Search -- no-floppy -- FS-UUID -- set de1ca47d1ca45277
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
# Menu entries you want to add after this comment. Be careful not to change
# The 'exec tail' line above.
### End/etc/grub. d/40_custom ###

Certificate --------------------------------------------------------------------------------------------------------------------------------------

As shown above, each menuentry represents a startup item, as shown in:

Menuentry "Windows 7 (loader) (on/dev/sda1 )"{
Insmod NTFS
Set root = '(hd0, 1 )'
Search -- no-floppy -- FS-UUID -- set de1ca47d1ca45277
Chainloader + 1
}

It indicates that the Windows 7 startup items are in the last one (my computer has a total of 9 startup items, generally 7, etc ). If you want to modify the boot item, you only need to modify the numbers in the red part. For example, set default = "8" indicates that the default boot item is the ninth in the list, that is, the Windows 7 system in your computer, "0" indicates the first startup item in the list. Set marked in blue
Timeout = 10 indicates that 10 seconds are left for the user to choose. Of course, if you suspect that too many startup items are too troublesome, you only need to delete the menuentry and its following braces, then the corresponding startup items will not appear at startup.


Another method can be adopted:

Will include the win7 boot item Section

### Begin/etc/grub. d/30_os-prober ###
Menuentry "Windows 7 (loader) (on/dev/sda1 )"{
Insmod NTFS
Set root = '(hd0, 1 )'
Search -- no-floppy -- FS-UUID -- set de1ca47d1ca45277
Chainloader + 1
}
### End/etc/grub. d/30_os-prober ###

Put the whole place in front of the following section:

### Begin/etc/grub. d/10_linux ###
Menuentry 'ubuntu, with Linux 2.6.32-31-generic '-- class Ubuntu -- class GNU-Linux -- class GNU -- class OS {
Recordfail
Insmod ext2
Set root = '(hd0, 9 )'
Search -- no-floppy -- FS-UUID -- set fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f
Linux/boot/vmlinuz-2.6.32-31-generic root = UUID = fd9c0f6c-5c20-4d95-b3f4-eebca82bea0f Ro quiet splash
Initrd/boot/initrd. img-2.6.32-31-generic
}
..... (Omitted here)
### End/etc/grub. d/10_linux ###

(Note: At this time, set default = "0" does not need to be modified, because at this time, win7 is ranked first. As for many other startup items, it is at the end of it, and you do not need to care about them .)


Address: http://hi.baidu.com/conperint/blog/item/65ba19ab20c406edfaed50fa.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.