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. maven在mac上的入门使用

    首先博主也是在入门学习,在学习maven时遇到了不少问题.查资料时发现网上maven的使用大多是win的,所以我打算写点maven在mac入门使用的笔记,希望可以帮助到跟我一样有困难的你们. 1.ht ...

  2. Mysql 应该选择什么引擎

    对于如何选择存储引擎,可以简答的归纳为一句话:“除非需要用到某些INNODB 不具备的特性,并且没有其他办法可以替代,否则都应该选择INNODB 引擎”.例如:如果要用到全文索引,建议优先考虑INNO ...

  3. NHibernate考察实例:简单映射

    建立一个Company类用来测试,对应的表为TBLCOMPANY.   1. 下载NHibernate(版本1.2.0.CR1),将NHibernate \bin\net-2.0下面的文件拷贝到lib ...

  4. Java学习-----单例模式

    一.问题引入 偶然想想到的如果把Java的构造方法弄成private,那里面的成员属性是不是只有通过static来访问呢:如果构造方法是private的话,那么有什么好处呢:如果构造方法是privat ...

  5. [转]JavaScript函数和数组总结

    转自:http://www.uml.org.cn/AJAX/201307264.asp 写的不错,对我有很多帮助,最近准备全面的学习研究一下ES5,先转载一下这篇文章. JavaScript函数 1. ...

  6. mysql主从复制 (超简单) 转载

    怎么安装mysql数据库,这里不说了,只说它的主从复制,步骤如下: 1.主从服务器分别作以下操作:   1.1.版本一致   1.2.初始化表,并在后台启动mysql   1.3.修改root的密码 ...

  7. iOS开发——OC篇&OC高级语法

    iOS开发高级语法之分类,拓展,协议,代码块详解 一:分类 什么是分类Category? 分类就是类的补充和扩展部分 补充和扩展的每个部分就是分类 分类本质上是类的一部分 分类的定义 分类也是以代码的 ...

  8. JAVA基础(1)之hashCode()

    JAVA基础(1)之hashCode() 看到一篇关于hashCode的文章(),写的很详细明白,瞬间有种恍然大悟的感觉,所以特地转过来.原文:http://blog.csdn.net/fenglib ...

  9. oracle insert &字符插入问题

    例如执行一下语句: insert into NSRXT_SP (SP_ID, SP_TITLE, SP_DESC, SP_URL, SP_TYPE, SP_SUB_TYPE, ADD_TIME, CZ ...

  10. linux wenjian

    文件锁是一种文件读写机制,在任何特定的时间只允许一个进程访问一个文件.利用这种机制能够使读写单个文件的过程变得更安全. 在这篇文章中,我们将探讨Linux中不同类型的文件锁,并通过示例程序来理解它们之 ...