ubuntu进入recovery mode

问题

由于ubuntu中另外一块硬盘出现问题,想要进入ubuntu recovery mode进行修复。按照网上的做法,在我的电脑上都无法进入,最后都走正常启动。但是我使用同样的方法在另外一台机器上就可以进入。以下方法针对那种无法进入recovery mode,但是可以进入normal mode修改grub的情况。


网上的方法

  1. Switch on your computer;
  2. Wait until the BIOS has finished loading, or has almost finished. (During this time you will probably see a logo of your computer manufacturer.)
  3. Quickly press and hold the Shift key (or Escape 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.)
  4. Select the line which starts with “Advanced options”.
  5. 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)
  6. Press Return and your machine will begin the boot process.
  7. 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.
  8. The root partition is mounted read-only. To mount it read/write, enter the command:mount -o remount,rw /
  9. 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 ShiftESCF10/F11/F12都没有看到进入recovery mode的菜单选项。后面看到可以修改grub,我就想着去看看grub文件的内容看看有啥发现。


解决办法

进入normal mode下,查看到原始的grub文件内容为:

/etc/default/grub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

根据Grub2/Setup 的文档说明,了解XXX_TIMEOUT_XXX参数的含义,因此做如下修改:

1
2
3
GRUB_HIDDEN_TIMEOUT=5
GRUB_HIDDEN_TIMEOUT_QUIET=false
GRUB_TIMEOUT=0

GRUB_HIDDEN_TIMEOUT=5等待5s然后进行启动,GRUB_HIDDEN_TIMEOUT_QUIET=false表示显示倒计时,GRUB_TIMEOUT=0设置为0,表示通过GRUB_HIDDEN_TIMEOUT来决定timeout。

通过上述的配置,在开机的时候可以看到一个倒计时,然后在这个阶段按ESC就可以进入recovery mode的菜单选项。


参考资料

Title:ubuntu进入recovery mode

Author:Victor Huang

Time:2019-08-11 / 14:08

Link:http://wowothink.com/f4def801/

License: Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)