linux 默认启动目录,Linux GRUB 2及修改默认启动项

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=10GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"GRUB_DEFAULT=saved

GRUB_DISABLE_SUBMENU=trueGRUB_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=10GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"GRUB_DEFAULT=saved

GRUB_DISABLE_SUBMENU=trueGRUB_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.0-327.el7.x86_64

Found initrd image:/boot/initramfs-3.10.0-327.el7.x86_64.img

Found linux image:/boot/vmlinuz-0-rescue-c9e1b1f7c9514da7a2e9448646555486

Found initrd image:/boot/initramfs-0-rescue-c9e1b1f7c9514da7a2e9448646555486.img

done

[root@rhel7~]#

4.Reboot and verify that while booting you see boot messages scrolling by.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值