mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-13 22:30:37 +08:00
translated
This commit is contained in:
parent
e5b3509f18
commit
424a42f3fd
@ -1,109 +0,0 @@
|
|||||||
[#]: subject: "How to Access the GRUB Menu in Virtual Machine"
|
|
||||||
[#]: via: "https://itsfoss.com/access-grub-virtual-machine/"
|
|
||||||
[#]: author: "Sagar Sharma https://itsfoss.com/author/sagar/"
|
|
||||||
[#]: collector: "lkxed"
|
|
||||||
[#]: translator: "geekpi"
|
|
||||||
[#]: reviewer: " "
|
|
||||||
[#]: publisher: " "
|
|
||||||
[#]: url: " "
|
|
||||||
|
|
||||||
How to Access the GRUB Menu in Virtual Machine
|
|
||||||
======
|
|
||||||
|
|
||||||
Most modern VMs are configured to skip the [GRUB bootloader][1] for a seamless experience.
|
|
||||||
|
|
||||||
However, you might need to access the GRUB menu at times. For example, if you want to switch back to the older kernel or get into recovery mode for [resetting the password][2].
|
|
||||||
|
|
||||||
> 💡 Reboot your VM and keep the Shift key pressed when it is booting up again. This should give you the GRUB menu.
|
|
||||||
|
|
||||||
In this quick article, I will be showing you two ways to access the GRUB menu in Linux running in a virtual machine:
|
|
||||||
|
|
||||||
- A temporary solution (when you have to access GRUB once or twice)
|
|
||||||
- A permanent solution (will show GRUB at every boot)
|
|
||||||
|
|
||||||
As most of the users are not going to interact with the grub on a daily basis, I will start with a temporary solution in which you can access the grub without any tweaks.
|
|
||||||
|
|
||||||
> 📋 I have used Ubuntu in the tutorial here but the steps should be valid for other Linux distributions as well.
|
|
||||||
|
|
||||||
### Access the GRUB bootloader in VM (Quick way)
|
|
||||||
|
|
||||||
If you want to access the GRUB occasionally, this is supposed to be the best way as it does not require any configuration.
|
|
||||||
|
|
||||||
Just reboot your system and keep the `shift` key pressed.
|
|
||||||
|
|
||||||
That's it!
|
|
||||||
|
|
||||||
You will have your grub menu without any time limit:
|
|
||||||
|
|
||||||
![Accessing grub menu in VM using shift key][3]
|
|
||||||
|
|
||||||
Pretty simple way. Isn't it?
|
|
||||||
|
|
||||||
But it will work for that specific boot only. So what if you want to have the grub on every boot? Refer to the given method.
|
|
||||||
|
|
||||||
### Enable Grub menu in virtual machines permanently (if you want to)
|
|
||||||
|
|
||||||
> 🚧 This method requires changing Grub config file in the command line. Please ensure that you are comfortable doing the edits in the terminal.
|
|
||||||
|
|
||||||
If you have to deal with the grub menu to access the other operating systems or change[boot from the older kernels][4] often, this method is just for you.
|
|
||||||
|
|
||||||
To make the grub accessible at every boot, you must make changes in the configuration file.
|
|
||||||
|
|
||||||
First, open the grub config file using the following command:
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo nano /etc/default/grub
|
|
||||||
```
|
|
||||||
|
|
||||||
Here, change the `GRUB_TIMEOUT_STYLE=hidden` to the `GRUB_TIMEOUT_STYLE=menu`:
|
|
||||||
|
|
||||||
![change grub timeout style][5]
|
|
||||||
|
|
||||||
Next, in the same config file, specify for how many seconds you want the grub to be displayed.
|
|
||||||
|
|
||||||
I would recommend 5 seconds as it seems to balance between not too long and short (yep, quite relatable):
|
|
||||||
|
|
||||||
```
|
|
||||||
GRUB_TIMEOUT=5
|
|
||||||
```
|
|
||||||
|
|
||||||
![configure grub timeout in ubuntu][6]
|
|
||||||
|
|
||||||
And finally, you can [save the changes and exit from the nano][7] text editor.
|
|
||||||
|
|
||||||
To activate the changes you made to the config file, update the grub using the following command:
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo update-grub
|
|
||||||
```
|
|
||||||
|
|
||||||
That's it. Reboot your system and the grub should be there for 5 seconds.
|
|
||||||
|
|
||||||
### How about theming GRUB?
|
|
||||||
|
|
||||||
You will get the grub bootloader in most of the Linux distros as it is quite simple to configure and gets the job done.
|
|
||||||
|
|
||||||
But by default, it's nothing apart from the black background and plain text. So we made a guide on how you can make it look dope:
|
|
||||||
|
|
||||||
I hope you will find this guide helpful and if you have any queries, let me know in the comments.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: https://itsfoss.com/access-grub-virtual-machine/
|
|
||||||
|
|
||||||
作者:[Sagar Sharma][a]
|
|
||||||
选题:[lkxed][b]
|
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[a]: https://itsfoss.com/author/sagar/
|
|
||||||
[b]: https://github.com/lkxed/
|
|
||||||
[1]: https://itsfoss.com/what-is-grub/
|
|
||||||
[2]: https://itsfoss.com/how-to-hack-ubuntu-password/
|
|
||||||
[3]: https://itsfoss.com/content/images/2023/07/access-GRUB-in-Ubuntu-VM.gif
|
|
||||||
[4]: https://itsfoss.com/boot-older-kernel-default/
|
|
||||||
[5]: https://itsfoss.com/content/images/2023/07/change-grub-style.webp
|
|
||||||
[6]: https://itsfoss.com/content/images/2023/07/configure-grub-timeout-in-ubuntu.webp
|
|
||||||
[7]: https://linuxhandbook.com/nano-save-exit/
|
|
@ -0,0 +1,109 @@
|
|||||||
|
[#]: subject: "How to Access the GRUB Menu in Virtual Machine"
|
||||||
|
[#]: via: "https://itsfoss.com/access-grub-virtual-machine/"
|
||||||
|
[#]: author: "Sagar Sharma https://itsfoss.com/author/sagar/"
|
||||||
|
[#]: collector: "lkxed"
|
||||||
|
[#]: translator: "geekpi"
|
||||||
|
[#]: reviewer: " "
|
||||||
|
[#]: publisher: " "
|
||||||
|
[#]: url: " "
|
||||||
|
|
||||||
|
如何访问虚拟机中的 GRUB 菜单
|
||||||
|
======
|
||||||
|
|
||||||
|
大多数现代虚拟机都配置为跳过 [GRUB 引导加载程序][1]以获得无缝体验。
|
||||||
|
|
||||||
|
但是,你有时可能需要访问 GRUB 菜单。例如,如果你想切换回旧内核或进入恢复模式以[重置密码][2]。
|
||||||
|
|
||||||
|
> 💡 重启虚拟机并在再次启动时按住 Shift 键。这将为你提供 GRUB 菜单。
|
||||||
|
|
||||||
|
在这篇简短的文章中,我将向你展示两种访问虚拟机中运行的 Linux 中的 GRUB 菜单的方法:
|
||||||
|
|
||||||
|
- 临时方案(当你需要访问 GRUB 一次或两次时)
|
||||||
|
- 永久方案(每次启动时都会显示 GRUB)
|
||||||
|
|
||||||
|
由于大多数用户不会每天与 grub 交互,因此我将从一个临时解决方案开始,你可以在其中无需任何调整即可访问 grub。
|
||||||
|
|
||||||
|
> 📋 我在此处的教程中使用了 Ubuntu,但这些步骤也适用于其他 Linux 发行版。
|
||||||
|
|
||||||
|
### 在虚拟机中访问 GRUB 引导加载程序(快速方式)
|
||||||
|
|
||||||
|
如果你偶尔想访问 GRUB,这应该是最好的方法,因为它不需要任何配置。
|
||||||
|
|
||||||
|
只需重新启动系统并按住 `shift` 键即可。
|
||||||
|
|
||||||
|
就是这样!
|
||||||
|
|
||||||
|
你将拥有没有任何时间限制的 grub 菜单:
|
||||||
|
|
||||||
|
![Accessing grub menu in VM using shift key][3]
|
||||||
|
|
||||||
|
很简单的方法。不是吗?
|
||||||
|
|
||||||
|
但它仅适用于特定的启动。那么如果你想在每次启动时都进入 grub 该怎么办呢? 请参考下面的方法。
|
||||||
|
|
||||||
|
### 永久在虚拟机中启用 Grub 菜单(如果你愿意)
|
||||||
|
|
||||||
|
> 🚧 此方法需要在命令行中更改 Grub 配置文件。请确保你能够轻松地在终端中进行编辑。
|
||||||
|
|
||||||
|
如果你需要处理 grub 菜单来访问其他操作系统或经常更改[从旧内核启动][4],那么此方法非常适合你。
|
||||||
|
|
||||||
|
要使 grub 在每次引导时都可访问,你必须在配置文件中进行更改。
|
||||||
|
|
||||||
|
首先,使用以下命令打开 grub 配置文件:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo nano /etc/default/grub
|
||||||
|
```
|
||||||
|
|
||||||
|
在这里,将 `GRUB_TIMEOUT_STYLE=hidden` 更改为 `GRUB_TIMEOUT_STYLE=menu`:
|
||||||
|
|
||||||
|
![change grub timeout style][5]
|
||||||
|
|
||||||
|
接下来,在同一个配置文件中,指定你希望 grub 显示的秒数。
|
||||||
|
|
||||||
|
我建议 5 秒,因为它似乎在太长和太短之间取得了平衡(是的,非常相关):
|
||||||
|
|
||||||
|
```
|
||||||
|
GRUB_TIMEOUT=5
|
||||||
|
```
|
||||||
|
|
||||||
|
![configure grub timeout in ubuntu][6]
|
||||||
|
|
||||||
|
最后,你可以[保存更改并退出 nano][7] 编辑器。
|
||||||
|
|
||||||
|
要激活对配置文件所做的更改,请使用以下命令更新 grub:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo update-grub
|
||||||
|
```
|
||||||
|
|
||||||
|
就是这样。重启动统,grub 应该会存在 5 秒钟。
|
||||||
|
|
||||||
|
### 将 GRUB 主题化如何?
|
||||||
|
|
||||||
|
大多数 Linux 发行版都会使用 grub 引导加载程序,因为它的配置非常简单,而且能完成工作。
|
||||||
|
|
||||||
|
但在默认情况下,除了黑色背景和纯文本外,它什么都不是。因此,我们制作了一份指南,教你如何让它看起来更漂亮:
|
||||||
|
|
||||||
|
希望本指南对你有所帮助,如果你有任何疑问,请在评论中告诉我。
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://itsfoss.com/access-grub-virtual-machine/
|
||||||
|
|
||||||
|
作者:[Sagar Sharma][a]
|
||||||
|
选题:[lkxed][b]
|
||||||
|
译者:[geekpi](https://github.com/geekpi)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]: https://itsfoss.com/author/sagar/
|
||||||
|
[b]: https://github.com/lkxed/
|
||||||
|
[1]: https://itsfoss.com/what-is-grub/
|
||||||
|
[2]: https://itsfoss.com/how-to-hack-ubuntu-password/
|
||||||
|
[3]: https://itsfoss.com/content/images/2023/07/access-GRUB-in-Ubuntu-VM.gif
|
||||||
|
[4]: https://itsfoss.com/boot-older-kernel-default/
|
||||||
|
[5]: https://itsfoss.com/content/images/2023/07/change-grub-style.webp
|
||||||
|
[6]: https://itsfoss.com/content/images/2023/07/configure-grub-timeout-in-ubuntu.webp
|
||||||
|
[7]: https://linuxhandbook.com/nano-save-exit/
|
Loading…
Reference in New Issue
Block a user