grub 不会显示自定义菜单项

awk*_*oob 5 grub2

我在虚拟机下运行 Ubuntu 12.04。我必须修改 grub 菜单,添加一些自定义条目。我尝试编辑/etc/grub.d/40_custom然后运行update-grub;但是,没有显示新的菜单条目。

这是我的40_custom文件的内容:

#!/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.
menuentry "System restart" {
    echo "System rebooting..."
    reboot
}
menuentry "System shutdown" {
    echo "System shutting down..."
    halt
}
menuentry "Other Linux" {
    set root=(hd0,1)
    linux /boot/vmlinuz 
    initrd /boot/initrd.img 
}
Run Code Online (Sandbox Code Playgroud)

这就是我得到的结果: 没有新条目

我从这个页面获取了菜单条目(关于 Arch,但我认为实际上出现在菜单中的条目应该没有区别)。

我也不能使用任何第三方软件之类的东西,我必须40_custom手动编辑文件或使用标准 Ubuntu 软件包提供的东西。

编辑: 这是ls -l /etc/grub.d | grep 40_custom输出:

-rw-r--r-- 1 root root  626 May  1 09:44 40_custom
-rw-r--r-- 1 root root  466 May  1 09:39 40_custom~
Run Code Online (Sandbox Code Playgroud)

moo*_*765 6

您需要对该文件的执行权限/etc/grub.d/40_custom

命令

sudo chmod +x /etc/grub.d/40_custom
Run Code Online (Sandbox Code Playgroud)

将为文件添加执行权限。

这样做之后,运行

sudo update-grub
Run Code Online (Sandbox Code Playgroud)

  • 我试过这个,但没有帮助 (2认同)