设为首页 收藏本站
查看: 671|回复: 0

[经验分享] Configure GRUB2 Boot Loader Settings In Ubuntu 16.04

[复制链接]

尚未签到

发表于 2017-11-19 16:56:56 | 显示全部楼层 |阅读模式
  As you probably know, GRUB2 is default boot loader for most Linux operating systems. GRUB stands for GRand Unified Bootloader. GRUB boot loader is the first program that runs when the computer starts. It is responsible for loading and transferring control to the operating system Kernel. Then, the Kernel takes charge, and initializes the rest of the operating system.

In this tutorial, we will be discussing about configuring some important GRUB2 Boot Loader’s settings in Ubuntu 16.04 LTS desktop. I tested this guide in Ubuntu 16.04 LTS desktop, however these instructions might work on all Linux operating systems that uses GRUB2 boot loader.

Configure GRUB2 Boot Loader settings.

Warning: The default configuration file for GRUB2 is /boot/grub/grub.cfg. You shouldn’t edit or modify this file, unless you are much familiar with GRUB2. This is the main file to boot into the Linux OS. If you do anything wrong with this file, then you will be surely end up with broken system. So, Don’t touch this file!

All settings related to the GRUB2 will be stored in /etc/default/grub file. Whatever the changes you made in this file will be reflected to the GRUB2.

Make a backup of /etc/default/grub file before making any changes.


sudo cp /etc/default/grub /etc/default/grub.bak
  Let us see the main options in the GRUB boot loader.
  The typical grub will look like below.


cat /etc/default/grub
  Sample output:


# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
  Whenever you made a change in this file, you must run the following command to apply the changes to the GRUB2.


sudo update-grub
  Let us do three important tweaks in the GRUB2 boot loader.

1. Select default OS (GRUB_DEFAULT)

We can select the default OS to boot using this option. If you set the value as “0”, the first operating system in the GRUB boot menu entry will boot. If you set it as “1”, the second OS will boot, and so on.

DSC0000.jpg

Also, if you have more than one OS in your system, you can boot the last operating system using the value GRUB_DEFAULT=saved. Whenever you reboot the system, the last operating system will start boot. Please note that you should add a line GRUB_SAVEDEFAULT=true to make this trick work.

DSC0001.jpg
  2. Set OS timeout (GRUB_TIMEOUT)

By default, the selected entry from the boot menu will start to boot in 10 seconds.

You can increase or decrease this timeout setting. If the value is “0”, the default OS will immediately start to boot. If the value is “5” , the boot menu will appear for 5 seconds, so that you can select which OS you want to load when the system starts.

3. Change GRUB background image

To change the GRUB background image, you need to copy your preferred image to /boot/grub/ location.

sudo cp my-own-background.png /boot/grub/
  Replace the image path with your own. You can use JPG/JPEG format images as well. But GRUB supports only 256 color JPG/JPEG image formats only. So, it is better to use PNG format images.
  Once you made the necessary changes in the GRUB file, Save and close it.
  To apply the changes, you must run the following command:


sudo update-grub
  You should see the following output:


Generating grub configuration file ...
Found background image: ostechnix.png
Found linux image: /boot/vmlinuz-4.4.0-15-generic
Found initrd image: /boot/initrd.img-4.4.0-15-generic
Found linux image: /boot/vmlinuz-4.2.0-34-generic
Found initrd image: /boot/initrd.img-4.2.0-34-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done
  Reboot and check whether the changes are working or not.

DSC0002.jpg

Please be mindful that you shouldn’t edit or modify GRUB2 settings in mission critical or production systems. I recommend you to test these settings in any virtual machine first, and then apply to the production systems.
  That’s all folks. I will be here soon with another Interesting article. If you find this guide helpful, please share it on your social and professional networks.
  Cheers!

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-408596-1-1.html 上篇帖子: .Net Core在Ubuntu上操作MySql折腾实录 下篇帖子: Ubuntu上latex+atom配置
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表