背景
在使用Ubuntu时,有时需要更改启动时间,或因图形化界面启动失败需要进入高级模式时,需要调整操作系统在启动时的选择时间.以下以Ubuntu 20.04为例.
如果能进入ubuntu系统或命令行
以管理员身份打开/boot/grub/grub.cfg:
找到下面语句的位置:
terminal_output gfxterm
if [ "
r
e
c
o
r
d
f
a
i
l
"
=
1
]
;
t
h
e
n
s
e
t
t
i
m
e
o
u
t
=
30
e
l
s
e
i
f
[
x
{recordfail}" = 1 ] ; then set timeout=30 else if [ x
recordfail"=1];thensettimeout=30elseif[xfeature_timeout_style = xy ] ; then
set timeout_style=hidden
set timeout=0
Fallback hidden-timeout code in case the timeout_style feature is
unavailable.
elif sleep --interruptible 0 ; then
set timeout=0
fi
fi
改成:
terminal_output gfxterm
if [ "
r
e
c
o
r
d
f
a
i
l
"
=
1
]
;
t
h
e
n
s
e
t
t
i
m
e
o
u
t
=
5
e
l
s
e
i
f
[
x
{recordfail}" = 1 ] ; then set timeout=5 else if [ x
recordfail"=1];thensettimeout=5elseif[xfeature_timeout_style = xy ] ; then
set timeout_style=menu
set timeout=5
Fallback hidden-timeout code in case the timeout_style feature is
unavailable.
elif sleep --interruptible 0 ; then
set timeout=5
fi
fi
重启动后会有选择项.可进入Advanced options for Ubuntu. 在Recovery Menu中选择root.
如果不能正常进入ubuntu系统
如果启动时无法进行 grub选项,并且无法打开 grub.cfg文件,可以考虑使用临时ubuntu系统进入.
- 准备U盘和Ubuntu系统镜像软件,制作启动盘.
- 更改电脑启动顺序,选择从U盘启动.
- 选择"Try Ubuntu",进入U盘下的Ubuntu系统.
- 进入/boot/grub/文件夹,修改grub.cfg的可写权限:chmod +w grub.cfg
- 按照上面所属修改,保存,重启即可进入grub.