The GRUB 2 boot loader makes sure that you can boot Linux. GRUB 2 is installed in the boot sector of your server’s hard drive and is configured to load a Linux kernel and the initramfs:
■ The kernel is the heart of the operating system, allowing users to interact with the hardware that is installed in the server.
■ The initramfs contains drivers that are needed to start your server. It contains a mini file system that is mounted during boot. In it are kernel modules that are needed during the rest of the boot process (for example, the LVM modules and SCSI modules for accessing disks that are not supported by default).

Normally, GRUB 2 works just fine and does not need much maintenance. In some cases, though, you might have to change its configuration. To apply changes to the GRUB 2 configuration, the starting point is the /etc/default/grub file. In this file, you’ll find options that tell GRUB what to do and how to do it.

[root@rhel7 ~]# cat /etc/default/grub
GRUB_TIMEOUT=
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
[root@rhel7 ~]#

The most important part that it configures is the GRUB-CMDLINE_LINUX option. This line contains boot arguments for the kernel on your server.

Modifying Default GRUB 2 Boot Options  

To apply modifications to the GRUB 2 boot loader, the file /etc/default/grub is your entry point; do not change the contents of the /boot/grub2/grub.cfg(不要直接修改这个配置文件) configuration file directly. The most important line in this file is GRUB_CMDLINE_ LINUX, which defines how the Linux kernel should be started. In this line, you can apply permanent fixes to the GRUB 2 configuration. Some likely candidates for removal are the options  rhgb  and  quiet(删除这两个参数后,启动时显示详细信息) . These options tell the kernel to hide all output while booting. That is nice to hide confusing messages for end users, but if you are a server administrator, you probably just want  to remove these options.

Another interesting parameter is GRUB_TIMEOUT. This defines the amount of time your server waits for you to access the GRUB 2 boot menu before it continues booting automatically.

 Applying Modifications to GRUB2  

In this exercise you’ll apply some changes to the GRUB2 boot configuration and write them to the /boot/grub2/grub.cfg configuration file.

  • 1.   Open the file /etc/default/grub with an editor and remove the  rhgb  and  quiet  options from the GRUB_CMDLINE_LINUX line.
  • 2.   From the same file, set the GRUB_TIMEOUT parameter to 10 seconds. Save changes to the file and close the editor.
[root@rhel7 ~]# cat /etc/default/grub
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap"
GRUB_DISABLE_RECOVERY="true"
[root@rhel7 ~]#
  • 3.   From the command line, type  grub2-mkconfig > /boot/grub2/grub.cfg  to write the changes to GRUB 2. (Note that instead of using the  redirector >  to write changes to the grub.cfg file, you could use the  -o  option. Both methods have the same result.)
[root@rhel7 ~]# grub2-mkconfig > /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.-.el7.x86_64
Found initrd image: /boot/initramfs-3.10.-.el7.x86_64.img
Found linux image: /boot/vmlinuz--rescue-c9e1b1f7c9514da7a2e9448646555486
Found initrd image: /boot/initramfs--rescue-c9e1b1f7c9514da7a2e9448646555486.img
done
[root@rhel7 ~]#
  • 4.   Reboot and verify that while booting you see boot messages scrolling by.

Linux GRUB 2及修改默认启动项的更多相关文章

  1. CentOS 7 添加win7启动项——修改默认启动项

    CentOS 7使用grub2引导启动,在win7之后装完CentOS再启动会丢失win7启动项. 首先,添加win7启动项,步骤如下: 1.使用root登陆系统 2.用文本编辑器打开 /boot/g ...

  2. 三个linux系统共存,修改默认启动

     一个mint,一个ubuntu,想要默认启动ubuntu,那么咱们这么来:修改启动顺序,我们需要修改Ubuntu的GRUB配置文件.使用常见的编辑程序如"gedit"就可以很方便 ...

  3. 安装ubuntu和windows双系统后,如何修改默认启动项

    在安装了Ubuntu16.04系统之后,系统会默认自启动Ubuntu16.04,而我们大多数情况下可能都在使用windows系统,不修改默认设置,不经意间便会启动了Ubuntu16.04,通过我的经历 ...

  4. win7 启动管理器修改默认启动项

    最近给我的超级本做了系统备份,以防万一,但是备份完成后,系统启动的时候总会首先进入Windows启动管理器,且默认启动项是Ghost,还需要选择一下才能进入Win7系统,如何解决这个问题呢? 方案一: ...

  5. Ubuntu - Grub2.0修改默认启动项

    1. 我的环境: Ubuntu 10.04   2. 关键位置和文件: /boot/grub/grub.cfg 文件: /etc/grub.d/ 目录: /etc/default/grub 文件:   ...

  6. linux deepin 12.12.1和Windows 7双系统修改默认启动项

    1.打开终端,输入 sudo gedit /etc/default/grub ,然后输入密码.2.在出来的文本编辑器中找到 GRUB_DEFAULT=0 一行,把0改为2(因为我的Windows 7在 ...

  7. 【Linux-CentOS】CentOS安装Win双系统后Win启动项丢失及默认启动项修改

    转载自:搁浅bky,有部分更正,建议看此文. 1.Windows启动项消失的原因:   在安装Win7.8/10系统+CentOS7双系统后,默认会将mbr(Main Boot Record)改写为g ...

  8. CentOS 7与 Windows双系统丢失Windows启动项及默认启动项修改

    1.Windows启动项消失的原因:   在安装Win7.8/10系统+CentOS7双系统后,默认会将mbr(Main Boot Record)改写为grub2,默认的CentOS7无法识别Wind ...

  9. Centos7多内核情况下修改默认启动内核方法

    1.1  进入grub.cfg配置文件存放目录/boot/grub2/并备份grub.cfg配置文件 [root@linux-node1 ~]# cd /boot/grub2/ [root@linux ...

随机推荐

  1. Linux 寻找安装路径

    1.whereis 语法:  # whereis [-bmsu] 文件或者目录名称  参数说 明:  -b : 只找二进制文件  -m: 只找在说明文件manual路径下的文件  -s : 只找sou ...

  2. jdbc中的Statement对象和Preparedstatement对象的区别,以及通过jdbc操作调用存储过程

    一. java.sql.*   和  javax.sql.*的包的类结构 |- Driver接口: 表示java驱动程序接口.所有的具体的数据库厂商要来实现此接口. |- connect(url, p ...

  3. Android学习----AndroidManifest.xml文件解析

    一个Android应用程序的结构: 一.关于AndroidManifest.xml AndroidManifest.xml 是每个android程序中必须的文件.它位于整个项目的根目录,描述了pack ...

  4. 关于一个隐藏和显示物品列表的demo

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...

  5. 打包静默安装参数(nsis,msi,InstallShield,InnoSetup)[转]

    有时我们在安装程序的时候,希望是静默安装的,不显示下一步下一步,这编访问来教大家如何来操作,现在常用的制作安装程序的软件有,  Microsoft Windows Installer  , Windo ...

  6. MongoDB-GRIDFS大文件系统

    gridfs 是一种在mongodb中存储大二进制文件的机制,使用gridfs的原因: 1.存储巨大的文件(视频图片). 2.利用GRIDFS可以简化需求. 3.GRIDFS 利用已经建立起来的复制以 ...

  7. Python几种创建list的方法的效率对比

    我们用 生成一个0到((1万倍n)-1)的list做例子 首先这种方式复杂度为平方级 ''' def test1(n): lst = [] for i in range(n*10000): lst = ...

  8. iOS开发——常用宏的定义

    有些时候,我们需要将代码简洁化,这样便于读代码.我们可以将一些不变的东东抽取出来,将变化的东西作为参数.定义为宏,这样在写的时候就简单多了. 下面例举了一些常用的宏定义和大家分享: 1. 判断设备的操 ...

  9. linux内核学习之二:编译内核

    在linux内核学习系列的第一课中讲述了搭建学习环境的过程(http://www.cnblogs.com/xiongyuanxiong/p/3523306.html),环境搭好后,马上就进入到下一环节 ...

  10. angular2 学习笔记 ( Http 请求)

    refer : https://angular.cn/docs/ts/latest/guide/server-communication.html https://xgrommx.github.io/ ...