清理新的Ubuntu Grub2启动菜单

Ubuntu adopted the new version of the Grub boot manager in version 9.10, getting rid of the old problematic menu.lst. Today we look at how to change the boot menu options in Grub2.

Ubuntu取消了旧的有问题的menu.lst,在版本9.10中采用了新版本的Grub引导管理器。 今天,我们来看看如何在Grub2中更改启动菜单选项。

Grub2 is a step forward in a lot of ways, and most of the annoying menu.lst issues from the past are gone. Still, if you’re not vigilant with removing old versions of the kernel, the boot list can still end up being longer than it needs to be.

GRUB2是在很多方面向前迈进了一步,而且大多数.LST从过去的问题恼人的菜单都不见了。 不过,如果您对删除旧版本的内核不保持警惕,则引导列表最终可能会比需要的更长。

sshot-1

Note: You may have to hold the SHIFT button on your keyboard while booting up to get this menu to show. If only one operating system is installed on your computer, it may load it automatically without displaying this menu.

注意:在启动时,可能必须按住键盘上的SHIFT键才能显示此菜单。 如果您的计算机上仅安装了一个操作系统,则它可能会自动加载而不显示此菜单。

Remove Old Kernel Entries

删除旧内核条目

The most common clean up task for the boot menu is to remove old kernel versions lying around on your machine.

引导菜单最常见的清理任务是删除计算机上旧的内核版本。

In our case we want to remove the 2.6.32-21-generic boot menu entries. In the past, this meant opening up /boot/grub/menu.lst…but with Grub2, if we remove the kernel package from our computer, Grub automatically removes those options.

在本例中,我们要删除2.6.32-21通用启动菜单项。 过去,这意味着要打开/boot/grub/menu.lst…,但是使用Grub2,如果我们从计算机中删除内核软件包,则Grub会自动删除这些选项。

To remove old kernel versions, open up Synaptic Package Manager, found in the System > Administration menu.

要删除旧的内核版本,请打开“系统>管理”菜单中的Synaptic软件包管理器。

When it opens up, type the kernel version that you want to remove in the Quick search text field. The first few numbers should suffice.

打开后,在“快速搜索”文本字段中输入要删除的内核版本。 前几个数字就足够了。

sshot-2

For each of the entries associated with the old kernel (e.g. linux-headers-2.6.32-21 and linux-image-2.6.32-21-generic), right-click and choose Mark for Complete Removal.

对于与旧内核相关联的每个条目(例如linux-headers-2.6.32-21和linux-image-2.6.32-21-generic),右键单击并选择Mark for Complete Removal

sshot-3

Click the Apply button in the toolbar and then Apply in the summary window that pops up. Close Synaptic Package Manager.

单击工具栏中的“应用”按钮,然后在弹出的摘要窗口中单击“应用”。 关闭Synaptic软件包管理器。

The next time you boot up your computer, the Grub menu will not contain the entries associated with the removed kernel version.

下次启动计算机时,Grub菜单将不包含与已删除的内核版本关联的条目。

sshot-4

Remove Any Option by Editing /etc/grub.d

通过编辑/etc/grub.d删除任何选项

If you need more fine-grained control, or want to remove entries that are not kernel versions, you must change the files located in /etc/grub.d.

如果您需要更细粒度的控制,或者想要删除不是内核版本的条目,则必须更改/etc/grub.d中的文件。

sshot-7

/etc/grub.d contains files that hold the menu entries that used to be contained in /boot/grub/menu.lst. If you want to add new boot menu entries, you would create a new file in this folder, making sure to mark it as executable.

/etc/grub.d包含用于保存曾经包含在/boot/grub/menu.lst中的菜单项的文件。 如果要添加新的启动菜单项,则应在此文件夹中创建一个新文件,并确保将其标记为可执行文件。

If you want to remove boot menu entries, as we do, you would edit files in this folder.

如果要像我们一样删除引导菜单项,则可以编辑此文件夹中的文件。

If we wanted to remove all of the memtest86+ entries, we could just make the 20_memtest86+ file non-executable, with the terminal command

如果我们想删除所有的memtest86 +条目,则可以使用terminal命令使20_memtest86 +文件不可执行。

sudo chmod –x 20_memtest86+

须藤chmod –x 20_memtest86 +

sshot-10

Followed by the terminal command

后跟终端命令

sudo update-grub

须藤更新

sshot-11

Note that memtest86+ was not found by update-grub because it will only consider executable files.

请注意,update-grub找不到memtest86 +,因为它只会考虑可执行文件。

However, instead, we’re going to remove the Serial console 115200 entry for memtest86+…

但是,相反,我们将删除memtest86 +的串行控制台115200条目…

Open a terminal window Applications > Accessories > Terminal. In the terminal window, type in the command:

打开终端窗口“应用程序”>“附件”>“终端”。 在终端窗口中,输入以下命令:

gksudo gedit /etc/grub.d/20_memtest86+

gksudo gedit /etc/grub.d/20_memtest86+

The menu entries are found at the bottom of this file.

菜单条目位于此文件的底部。

sshot-5

Delete the menu entry for serial console 115200.

删除串行控制台115200的菜单项。

Note: Commenting out the menu entry will not work — it must be deleted. Copy it to a different file if you’re worried you might need it later.

注意:注释掉菜单项将不起作用-必须将其删除。 如果担心以后可能需要将其复制到其他文件。

sshot-xx

Save and close this file. In the terminal window you opened, enter in the command

保存并关闭此文件。 在打开的终端窗口中,输入命令

sudo update-grub

须藤更新

Note: If you don’t run update-grub, the boot menu options will not change!

注意:如果您不运行update-grub,则引导菜单选项将不会更改!

sshot-8

Now, the next time you boot up, that strange entry will be gone, and you’re left with a simple and clean boot menu.

现在,下次启动时,该奇怪的条目将消失,您将获得一个简单干净的启动菜单。

sshot-9

Conclusion

结论

While changing Grub2’s boot menu may seem overly complicated to legacy Grub masters, for normal users, Grub2 means that you won’t have to change the boot menu that often. Fortunately, if you do have to do it, the process is still pretty easy.

虽然对于传统的Grub主用户而言,更改Grub2的启动菜单似乎过于复杂,但是对于普通用户而言,Grub2意味着您不必经常更改启动菜单。 幸运的是,如果必须这样做,该过程仍然非常容易。

For more detailed information about how to change entries in Grub2, this Ubuntu forum thread is a great resource. If you’re using an older version of Ubuntu, check out our article on how to clean up Ubuntu grub boot menu after upgrades.

有关如何更改Grub2中条目的更多详细信息, 此Ubuntu论坛线程是一个不错的资源。 如果您使用的是旧版Ubuntu,请查看有关升级后如何清理Ubuntu grub引导菜单的文章。

翻译自: https://www.howtogeek.com/howto/17787/clean-up-the-new-ubuntu-grub2-boot-menu/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值