Welcome 微信登录

首页 / 操作系统 / Linux / Grub2 添加自定义启动项

此文非教程,仅作记录之用。目的:为了从硬盘加载Clonezilla live,添加自定义启动项预期结果:BIOS启动后,shift键后进入Grub菜单,可以选择加载Clonezilla live步骤:
1. 在Grub2的/etc/grub.d/40_custom里加入menuentry。
2. 用update-grub2 更新/boot/grub/grub.cfg 这个启动配置文件。
3. 重启问题:
1. Be careful not to change the "exec tail" line above.40_custom 文件如下所示。不要去改动前面两行,因为"exec tail -n +3 $0",已经暗示我们这个文件会从第三行开始读取有效配置。这点可以从update-grub2后生成的grub.cfg 中得到印证。所以如果你想要改任何的东东,哪怕是加注释或者空行。需要去更新正确的行数到-n后面。#!/bin/sh
exec tail -n +3 $0 
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the "exec tail" line above.比如,有人希望在update-grub2时候看到有处理40_custom的动作,在"exec tail -n +3 $0"前面加入了
echo “processing the 40_custom ” 1>2&
那就把你的+3改成+4就ok了,就像下面那样。#!/bin/sh
echo "processing 40_custom " 1>&2
exec tail -n +4 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the "exec tail" line above.所以,不要只看注释写的,说不动"exec tail‘那句话就ok,你不动那句,动了它周边的位置,也会有问题哦~~2. Simply type the menu entries you want to add after this comment.
把要添加的menuentry直接紧跟着40_custom的注释之后,不要添加空行。否则会在grub.cfg 里也产生空行,这样启动的时候Grub2读grub.cfg 产生启动选项的时候,会不显示你添加的东东。
正确定制如下,
#!/bin/sh
echo "processing 40_custom " 1>&2
exec tail -n +4 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the "exec tail" line above.
menuentry "Clonezilla live" {
    ...
    your customized boot entry
    ...
}虚拟机VirtualBox中Ubuntu无法全屏解决方法Ubuntu 10.10搭建svn服务器相关资讯      Grub  grub2 
  • Ubuntu下Grub配置详解  (今 14:57)
  • GRUB2 的零日漏洞影响 Linux 用户  (12/18/2015 07:40:06)
  • 修复Linux中的“提供类似行编辑的  (07/29/2015 13:18:34)
  • GRUB官方文档翻译-v1.01 PDF  (04月09日)
  • Linux系统教程:设置GRUB菜单密码  (12/15/2015 21:30:02)
  • Linux操作系统启动管理器-GRUB  (05/09/2015 12:06:59)
本文评论 查看全部评论 (0)
表情: 姓名: 字数