问题
由于ubuntu中另外一块硬盘出现问题,想要进入ubuntu recovery mode进行修复。按照网上的做法,在我的电脑上都无法进入,最后都走正常启动。但是我使用同样的方法在另外一台机器上就可以进入。以下方法针对那种无法进入recovery mode,但是可以进入normal mode修改grub的情况。
网上的方法
- Switch on your computer;
- Wait until the BIOS has finished loading, or has almost finished. (During this time you will probably see a logo of your computer manufacturer.)
- Quickly press and hold the
Shift
key (orEscape
key on some computers), which will bring up the GNU GRUB menu. (If you see the Ubuntu logo, you’ve missed the point where you can enter the GRUB menu.)- Select the line which starts with “Advanced options”.
- Select the line ending with
(recovery mode)
, probably the second line, something like:Ubuntu GNU/Linux, with Linux 3.8.0-26-generic (recovery mode)- Press Return and your machine will begin the boot process.
- After a few moments, your workstation should display a menu with a number of options. One of the options (you may need to scroll down to the bottom of the list) will be
Drop to root shell prompt
. Press Return with this option highlighted.- The root partition is mounted read-only. To mount it read/write, enter the command:
mount -o remount,rw /
- If you have
/home
,/boot
,/tmp
, or any other mount point on a separate partition, you can mount them with the command:mount --all
按照上述的步骤,无论我怎么按left Shift
、ESC
、F10/F11/F12
都没有看到进入recovery mode的菜单选项。后面看到可以修改grub
,我就想着去看看grub
文件的内容看看有啥发现。
解决办法
进入normal mode下,查看到原始的grub
文件内容为:
1 | # If you change this file, run 'update-grub' afterwards to update |
根据Grub2/Setup 的文档说明,了解XXX_TIMEOUT_XXX
参数的含义,因此做如下修改:
1 | GRUB_HIDDEN_TIMEOUT=5 |
GRUB_HIDDEN_TIMEOUT=5
等待5s然后进行启动,GRUB_HIDDEN_TIMEOUT_QUIET=false
表示显示倒计时,GRUB_TIMEOUT=0
设置为0,表示通过GRUB_HIDDEN_TIMEOUT
来决定timeout。
通过上述的配置,在开机的时候可以看到一个倒计时,然后在这个阶段按ESC
就可以进入recovery mode的菜单选项。