ubuntu更改启动顺序

在ubuntu中修改启动配置。

启动相关grub2主要包含下面三个文件:1.   /boot/grub/grub.cfg 文件    2.   /etc/grub.d/ 文件夹   3.   /etc/default/grub 文件,可以通过修改这三个文件来修改启动项

链接:http://blog.csdn.net/zhu_liangwei/article/details/7847034

更改启动顺序,验证过的两种方式

1、修改 /etc/default/grub 文件

打开文件

sudo gedit /etc/default/grub

修改文件

GRUB_DEFAULT=0     #更改数字设置默认启动项

更新

sudo update-grub



 1 # If you change this file, run ‘update-grub‘ afterwards to update
 2 # /boot/grub/grub.cfg.
 3 # For full documentation of the options in this file, see:
 4 #   info -f grub -n ‘Simple configuration‘
 5
 6 GRUB_DEFAULT=7     #更改数字设置默认启动项
 7 #GRUB_HIDDEN_TIMEOUT=0
 8 GRUB_HIDDEN_TIMEOUT_QUIET=true
 9 GRUB_TIMEOUT=10
10 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
11 GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
12 GRUB_CMDLINE_LINUX=""
13
14 # Uncomment to enable BadRAM filtering, modify to suit your needs
15 # This works with Linux (no patch required) and with any kernel that obtains
16 # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
17 #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
18
19 # Uncomment to disable graphical terminal (grub-pc only)
20 #GRUB_TERMINAL=console
21
22 # The resolution used on graphical terminal
23 # note that you can use only modes which your graphic card supports via VBE
24 # you can see them in real GRUB with the command `vbeinfo‘
25 #GRUB_GFXMODE=640x480
26
27 # Uncomment if you don‘t want GRUB to pass "root=UUID=xxx" parameter to Linux
28 #GRUB_DISABLE_LINUX_UUID=true
29
30 # Uncomment to disable generation of recovery mode menu entries
31 #GRUB_DISABLE_RECOVERY="true"
32
33 # Uncomment to get a beep at grub start
34 #GRUB_INIT_TUNE="480 440 1"

配置文件详解 http://lesca.me/archives/manage-grub2-config-file.html

修改 /boot/grub/grub.cfg文件,使用sudo update-grub会被覆盖掉。

打开文件

sudo gedit /boot/grub/grub.cfg

修改文件

set default = ‘0‘   修改数字

 
  1 #
  2 # DO NOT EDIT THIS FILE
  3 #
  4 # It is automatically generated by grub-mkconfig using templates
  5 # from /etc/grub.d and settings from /etc/default/grub
  6 #
  7
  8 ### BEGIN /etc/grub.d/00_header ###
  9 if [ -s $prefix/grubenv ]; then
 10   set have_grubenv=true
 11   load_env
 12 fi
 13 set default="7"
 14 if [ "${prev_saved_entry}" ]; then
 15   set saved_entry="${prev_saved_entry}"
 16   save_env saved_entry
 17   set prev_saved_entry=
 18   save_env prev_saved_entry
 19   set boot_once=true
 20 fi
 21
 22 function savedefault {
 23   if [ -z "${boot_once}" ]; then
 24     saved_entry="${chosen}"
 25     save_env saved_entry
 26   fi
 27 }
 28
 29 function recordfail {
 30   set recordfail=1
 31   if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
 32 }
 33
 34 function load_video {
 35   insmod vbe
 36   insmod vga
 37   insmod video_bochs
 38   insmod video_cirrus
 39 }
 40
 41 insmod part_msdos
 42 insmod ext2
 43 set root=‘(hd0,msdos7)‘
 44 search --no-floppy --fs-uuid --set=root dea69c19-08d2-433a-89b9-f917b6d5cce4
 45 if loadfont /usr/share/grub/unicode.pf2 ; then
 46   set gfxmode=auto
 47   load_video
 48   insmod gfxterm
 49   insmod part_msdos
 50   insmod ext2
 51   set root=‘(hd0,msdos7)‘
 52   search --no-floppy --fs-uuid --set=root dea69c19-08d2-433a-89b9-f917b6d5cce4
 53   set locale_dir=($root)/boot/grub/locale
 54   set lang=zh_CN
 55   insmod gettext
 56 fi
 57 terminal_output gfxterm
 58 if [ "${recordfail}" = 1 ] ; then
 59   set timeout=30
 60 else
 61   set timeout=10
 62 fi
 63 ### END /etc/grub.d/00_header ###
 64
 65 ### BEGIN /etc/grub.d/05_debian_theme ###
 66 set menu_color_normal=white/black
 67 set menu_color_highlight=black/light-gray
 68 if background_color 44,0,30; then
 69   clear
 70 fi
 71 ### END /etc/grub.d/05_debian_theme ###
 72
 73 ### BEGIN /etc/grub.d/10_linux ###
 74 function gfxmode {
 75     set gfxpayload="${1}"
 76     if [ "${1}" = "keep" ]; then
 77         set vt_handoff=vt.handoff=7
 78     else
 79         set vt_handoff=
 80     fi
 81 }
 82 if [ "${recordfail}" != 1 ]; then
 83   if [ -e ${prefix}/gfxblacklist.txt ]; then
 84     if hwmatch ${prefix}/gfxblacklist.txt 3; then
 85       if [ ${match} = 0 ]; then
 86         set linux_gfx_mode=keep
 87       else
 88         set linux_gfx_mode=text
 89       fi
 90     else
 91       set linux_gfx_mode=text
 92     fi
 93   else
 94     set linux_gfx_mode=keep
 95   fi
 96 else
 97   set linux_gfx_mode=text
 98 fi
 99 export linux_gfx_mode
100 if [ "${linux_gfx_mode}" != "text" ]; then load_video; fi#********************这是一个启动项,启动项0
101 menuentry ‘Ubuntu,Linux 3.2.0-101-generic‘ --class ubuntu --class gnu-linux --class gnu --class os {
102     recordfail
103     gfxmode $linux_gfx_mode
104     insmod gzio
105     insmod part_msdos
106     insmod ext2
107     set root=‘(hd0,msdos7)‘
108     search --no-floppy --fs-uuid --set=root dea69c19-08d2-433a-89b9-f917b6d5cce4
109     linux    /boot/vmlinuz-3.2.0-101-generic root=UUID=dea69c19-08d2-433a-89b9-f917b6d5cce4 ro   quiet splash $vt_handoff
110     initrd    /boot/initrd.img-3.2.0-101-generic
111 }
112 menuentry ‘Ubuntu, with Linux 3.2.0-101-generic (recovery mode)‘ --class ubuntu --class gnu-linux --class gnu --class os {
113     recordfail
114     insmod gzio
115     insmod part_msdos
116     insmod ext2
117     set root=‘(hd0,msdos7)‘
118     search --no-floppy --fs-uuid --set=root dea69c19-08d2-433a-89b9-f917b6d5cce4
119     echo    ‘载入 Linux 3.2.0-101-generic ...‘
120     linux    /boot/vmlinuz-3.2.0-101-generic root=UUID=dea69c19-08d2-433a-89b9-f917b6d5cce4 ro recovery nomodeset
121     echo    ‘载入初始化内存盘...‘
122     initrd    /boot/initrd.img-3.2.0-101-generic
123 }
124 menuentry ‘Ubuntu,Linux 3.19.0-68-generic‘ --class ubuntu --class gnu-linux --class gnu --class os {
125     recordfail
126     gfxmode $linux_gfx_mode
127     insmod gzio
128     insmod part_msdos
129     insmod ext2
130     set root=‘(hd0,msdos7)‘
131     search --no-floppy --fs-uuid --set=root dea69c19-08d2-433a-89b9-f917b6d5cce4
132     linux    /boot/vmlinuz-3.19.0-68-generic root=UUID=dea69c19-08d2-433a-89b9-f917b6d5cce4 ro   quiet splash $vt_handoff
133     initrd    /boot/initrd.img-3.19.0-68-generic
134 }
135 menuentry ‘Ubuntu, with Linux 3.19.0-68-generic (recovery mode)‘ --class ubuntu --class gnu-linux --class gnu --class os {
136     recordfail
137     insmod gzio
138     insmod part_msdos
139     insmod ext2
140     set root=‘(hd0,msdos7)‘
141     search --no-floppy --fs-uuid --set=root dea69c19-08d2-433a-89b9-f917b6d5cce4
142     echo    ‘载入 Linux 3.19.0-68-generic ...‘
143     linux    /boot/vmlinuz-3.19.0-68-generic root=UUID=dea69c19-08d2-433a-89b9-f917b6d5cce4 ro recovery nomodeset
144     echo    ‘载入初始化内存盘...‘
145     initrd    /boot/initrd.img-3.19.0-68-generic
146 }
147 submenu "Previous Linux versions" {
148 menuentry ‘Ubuntu,Linux 3.2.0-105-generic‘ --class ubuntu --class gnu-linux --class gnu --class os {
149     recordfail
150     gfxmode $linux_gfx_mode
151     insmod gzio
152     insmod part_msdos
153     insmod ext2
154     set root=‘(hd0,msdos7)‘
155     search --no-floppy --fs-uuid --set=root dea69c19-08d2-433a-89b9-f917b6d5cce4
156     linux    /boot/vmlinuz-3.2.0-105-generic root=UUID=dea69c19-08d2-433a-89b9-f917b6d5cce4 ro   quiet splash $vt_handoff
157     initrd    /boot/initrd.img-3.2.0-105-generic
158 }
159 menuentry ‘Ubuntu, with Linux 3.2.0-105-generic (recovery mode)‘ --class ubuntu --class gnu-linux --class gnu --class os {
160     recordfail
161     insmod gzio
162     insmod part_msdos
163     insmod ext2
164     set root=‘(hd0,msdos7)‘
165     search --no-floppy --fs-uuid --set=root dea69c19-08d2-433a-89b9-f917b6d5cce4
166     echo    ‘载入 Linux 3.2.0-105-generic ...‘
167     linux    /boot/vmlinuz-3.2.0-105-generic root=UUID=dea69c19-08d2-433a-89b9-f917b6d5cce4 ro recovery nomodeset
168     echo    ‘载入初始化内存盘...‘
169     initrd    /boot/initrd.img-3.2.0-105-generic
170 }
171 menuentry ‘Ubuntu,Linux 3.2.0-102-generic‘ --class ubuntu --class gnu-linux --class gnu --class os {
172     recordfail
173     gfxmode $linux_gfx_mode
174     insmod gzio
175     insmod part_msdos
176     insmod ext2
177     set root=‘(hd0,msdos7)‘
178     search --no-floppy --fs-uuid --set=root dea69c19-08d2-433a-89b9-f917b6d5cce4
179     linux    /boot/vmlinuz-3.2.0-102-generic root=UUID=dea69c19-08d2-433a-89b9-f917b6d5cce4 ro   quiet splash $vt_handoff
180     initrd    /boot/initrd.img-3.2.0-102-generic
181 }
182 menuentry ‘Ubuntu, with Linux 3.2.0-102-generic (recovery mode)‘ --class ubuntu --class gnu-linux --class gnu --class os {
183     recordfail
184     insmod gzio
185     insmod part_msdos
186     insmod ext2
187     set root=‘(hd0,msdos7)‘
188     search --no-floppy --fs-uuid --set=root dea69c19-08d2-433a-89b9-f917b6d5cce4
189     echo    ‘载入 Linux 3.2.0-102-generic ...‘
190     linux    /boot/vmlinuz-3.2.0-102-generic root=UUID=dea69c19-08d2-433a-89b9-f917b6d5cce4 ro recovery nomodeset
191     echo    ‘载入初始化内存盘...‘
192     initrd    /boot/initrd.img-3.2.0-102-generic
193 }
194 }
195 ### END /etc/grub.d/10_linux ###
196
197 ### BEGIN /etc/grub.d/20_linux_xen ###
198 ### END /etc/grub.d/20_linux_xen ###
199
200 ### BEGIN /etc/grub.d/20_memtest86+ ###
201 menuentry "Memory test (memtest86+)" {
202     insmod part_msdos
203     insmod ext2
204     set root=‘(hd0,msdos7)‘
205     search --no-floppy --fs-uuid --set=root dea69c19-08d2-433a-89b9-f917b6d5cce4
206     linux16    /boot/memtest86+.bin
207 }
208 menuentry "Memory test (memtest86+, serial console 115200)" {
209     insmod part_msdos
210     insmod ext2
211     set root=‘(hd0,msdos7)‘
212     search --no-floppy --fs-uuid --set=root dea69c19-08d2-433a-89b9-f917b6d5cce4
213     linux16    /boot/memtest86+.bin console=ttyS0,115200n8
214 }
215 ### END /etc/grub.d/20_memtest86+ ###
216
217 ### BEGIN /etc/grub.d/30_os-prober ###
218 menuentry "Windows 7 (loader) (on /dev/sda2)" --class windows --class os {
219     insmod part_msdos
220     insmod ntfs
221     set root=‘(hd0,msdos2)‘
222     search --no-floppy --fs-uuid --set=root 40B2F9AEB2F9A894
223     chainloader +1
224 }
225 menuentry "Windows 7 (loader) (on /dev/sda3)" --class windows --class os {
226     insmod part_msdos
227     insmod ntfs
228     set root=‘(hd0,msdos3)‘
229     search --no-floppy --fs-uuid --set=root 0007D948000E6321
230     chainloader +1
231 }
232 set timeout_style=menu
233 if [ "${timeout}" = 0 ]; then
234   set timeout=10
235 fi
236 ### END /etc/grub.d/30_os-prober ###
237
238 ### BEGIN /etc/grub.d/30_uefi-firmware ###
239 ### END /etc/grub.d/30_uefi-firmware ###
240
241 ### BEGIN /etc/grub.d/40_custom ###
242 # This file provides an easy way to add custom menu entries.  Simply type the
243 # menu entries you want to add after this comment.  Be careful not to change
244 # the ‘exec tail‘ line above.
245 ### END /etc/grub.d/40_custom ###
246
247 ### BEGIN /etc/grub.d/41_custom ###
248 if [ -f  $prefix/custom.cfg ]; then
249   source $prefix/custom.cfg;
250 fi
251 ### END /etc/grub.d/41_custom ###
时间: 2024-08-18 21:22:58

ubuntu更改启动顺序的相关文章

如何修改Grub中Windows 和 Ubuntu的启动顺序

情景: 安装了window,然后又安装了Ubuntu OS , 电脑打开后默认启动Ubuntu OS 目的: 希望默认启动Ubuntu OS 实现方式: 进入Ubuntu OS, 打开Terminal,执行以下命令: $ sudo vim /etc/default/grub 将GRUB_DEFAULT=0  修改为: GRUB_DEFAULT=4 重启电脑即可.

更改ubuntu多系统启动顺序

电脑上双系统,启动时界面如下 ubuntu advance ubuntu option windows 在/boot/grub/grub.cfg中,查看到可以简单的修改/etc/defaulg/grub文件就可以更改启动顺序. 于是打开/etc/defaulg.grub,在阅读开头的说明后,将defaulte值由0更改为2后,运行grub-update,有一个错误,忽略,重启后就将默认启动改会了windows,并能正常启动windows和ubuntu.

[CrunchBang]修改win+ubuntu 双 系统菜单的 启动顺序 引导

说到启动就不得不说GRUB,Linux下大名鼎鼎的启动管理工具(曾经的LILO已经风光不再),当然现在已经是GRUB2了,GRUB2和GRUB最重要的区别就是,GRUB存放系统启动信息的文件为/boot/grub/menu.lst,而GRUB2则为/boot/grub/grub.cfg.由于ubuntu10.10采用的是GRUB2,所以这里主要讲GRUB2. 终端输入gedit /boot/grub/grub.cfg,打开这个文件,开头几行注释如下: # # DO NOT EDIT THIS F

修改ubuntu开机启动项顺序 grub设置 删除多余内核

1 最简单方法,装个软件,图形化操作. sudo apt-get install startupmanager 安装启动项管理器 系统——系统管理——启动项管理器,后面不解释.然后会自动按照配置修改grub.cfg文件了. 2 然而,grub修改开机启动菜单,会自动把最新的Ubuntu放在第一位,把Windows放在最后一个.我们经常希望把Windows调整到靠前的位置,可能还会修改默认的启动项和等待时间等.解决方案如下: 1.找到grub配置,打开配置文档,在终端里输入命令: sudo ged

ubuntu 开机启动

1.2配置jdk环境变量 安装是自动的,但是配置需要自己动手了. 1.2.1修改用户环境变量 ? 1 $ vi /home/fancy(你的用户名)/.bashrc 在 .bashrc文件中加入: ? 1 2 3 export JAVA_HOME="/usr/lib/jvm/java-6-sun" export CLASSPATH="$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib" export PATH="$PA

修改grub启动顺序

1. 其实就是修改/boot/grub/grub.cfg这个文件,从后缀就看得出这是一个配置文件,虽然linux不区分这后缀,这个后缀是个用户看的. 2. 看了下这个文件,其实我也不理解里面的全部东西,能够理解他的一些语法,但是没能理解他的本意,不过看到后面我既然发现menuentry的顺序就是开机的启动顺序,于是我把这个顺序修改了一下就好了.这样之后就是win7作为第一启动项了,之前我们看到的情况应该是"Ubuntu"在最前面,然后window7在最后面,这样修改后就ok,里面还有背

Ubuntu 16.04设置rc.local开机启动命令/脚本的方法(通过update-rc.d管理Ubuntu开机启动程序/服务)

注意:rc.local脚本里面启动的用户默认为root权限. 一.rc.local脚本 rc.local脚本是一个Ubuntu开机后会自动执行的脚本,我们可以在该脚本内添加命令行指令.该脚本位于/etc/路径下,需要root权限才能修改. 该脚本具体格式如下: #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the scrip

ubuntu为什么没有/etc/inittab文件? 深究ubuntu的启动流程分析

最近,因和队友一起做linux开发,因为用的不是同一版本linux(他用arch, 我用ubuntu),再配置上经常就不一样,就如这个inittab文件,于是深究了一下原因: Linux 内核启动 init ,init进程ID是1,是所有进程的父进程,所有进程由它控制. Ubuntu 的启动由upstart控制,自9.10后不再使用/etc/event.d目录的配置文件,改为/etc/init. 查看当前的运行级别,Ubuntu 桌面默认是2. ? 1 runlevel Ubuntu 的系统运行

修改grub默认启动顺序

grub现在有两个版本,一个grub,一个grub2,两个版本的操作不太一样. 装centos的朋友很有可能是grub.我电脑装的是ubuntu14.04,为grub2.我演示grub2的过程. GRUB默认启动顺序修改 GRUB2的默认启动顺序修改 首先我们cd到ubuntu的/boot/grub目录下,该目录下有个文件grub.cfg,就是设置默认启动的文件. 刚装ubuntu的朋友很可能会遇到这样的问题.因为ubuntu系统本来是让这个文件不可写的. 如下查看grub.cfg文件的权限就可