[200XRP悬赏] Ubuntu10.04 Server 每次重启停在 GNU GRUB 菜单

2014-01-21 07:23:54 +08:00
 andybest
因为之前主机意外停机导致 VPS 无法启动,VPS 提供商的的技术给我重装了 GRUB
现在每次执行 reboot 后系统都卡在:


必须按一下回车选择第一个才可以进入系统,十分郁闷
尝试修改 /boot/grub/grub.cfg 并执行 sudo update-grub 没有任何效果
/boot/grub/grub.cfg 的完整文件:
GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=3
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX=""

# 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_LINUX_RECOVERY="true"

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

请教如何恢复与之前一样,可以 reboot 后自动进入系统不要卡在 GNU GRUB
200XRP感谢!感谢! :)
4853 次点击
所在节点    问与答
21 条回复
vking
2014-01-21 07:57:07 +08:00
我的vps也是这样,不过无所谓,反正几个月都重启不了几次。
andybest
2014-01-21 07:59:24 +08:00
@vking 谢谢,的确是影响不大,但感觉别扭,还是想解决下...
passluo
2014-01-21 08:05:54 +08:00
把hidden time out 设置个时间,再更新一下grub设置就可以了,我之前在机房给服务器装Ubuntu也是这个样子的…不知道为什么…
andybest
2014-01-21 08:18:35 +08:00
@passluo 谢谢,已试过设置:
GRUB_HIDDEN_TIMEOUT = 1
然后运行
sudo update-grub

重启仍然卡在 GRUB 界面
jkeylu
2014-01-21 08:27:58 +08:00
你最近有添加什么服务开机启动的吗?很有可能是这个服务的启动脚本有问题才这样,起码以前我遇到的是这个情况!
Esay
2014-01-21 08:30:40 +08:00
andybest
2014-01-21 08:30:52 +08:00
@jkeylu 就是新安装的系统,因为VPS服务器意外宕机导致无法进入系统,提供商帮我重新安装了GRUB后成了这样,我没安装过任何东西。
Esay
2014-01-21 08:32:47 +08:00
不小心发出去了。

试试添加这些内容

https://bbs.archlinux.org/viewtopic.php?id=138446#p1078788
andybest
2014-01-21 08:33:13 +08:00
@Esay 看了半天没明白。。。恕我愚钝,具体是咋弄呢。。
xiiing
2014-01-21 08:54:56 +08:00
# 这是我这台电脑的grub.cfg,也是10.04,或许可以参考
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
set saved_entry=${prev_saved_entry}
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi

function savedefault {
if [ -z ${boot_once} ]; then
saved_entry=${chosen}
save_env saved_entry
fi
}

function recordfail {
set recordfail=1
if [ -n ${have_grubenv} ]; then if [ -z ${boot_once} ]; then save_env recordfail; fi; fi
}
insmod ext2
set root='(hd0,4)'
search --no-floppy --fs-uuid --set 6cc30560-a6f7-449b-bafe-2ae045026d04
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
if terminal_output gfxterm ; then true ; else
# For backward compatibility with versions of terminal.mod that don't
# understand terminal_output
terminal gfxterm
fi
fi
insmod ext2
set root='(hd0,4)'
search --no-floppy --fs-uuid --set 6cc30560-a6f7-449b-bafe-2ae045026d04
set locale_dir=($root)/boot/grub/locale
set lang=en
insmod gettext
if [ ${recordfail} = 1 ]; then
set timeout=-1
else
set timeout=10
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Ubuntu, with Linux 2.6.32-55-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,4)'
search --no-floppy --fs-uuid --set 6cc30560-a6f7-449b-bafe-2ae045026d04
linux /boot/vmlinuz-2.6.32-55-generic root=UUID=6cc30560-a6f7-449b-bafe-2ae045026d04 ro quiet splash
initrd /boot/initrd.img-2.6.32-55-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-55-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,4)'
search --no-floppy --fs-uuid --set 6cc30560-a6f7-449b-bafe-2ae045026d04
echo 'Loading Linux 2.6.32-55-generic ...'
linux /boot/vmlinuz-2.6.32-55-generic root=UUID=6cc30560-a6f7-449b-bafe-2ae045026d04 ro single
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-2.6.32-55-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-54-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,4)'
search --no-floppy --fs-uuid --set 6cc30560-a6f7-449b-bafe-2ae045026d04
linux /boot/vmlinuz-2.6.32-54-generic root=UUID=6cc30560-a6f7-449b-bafe-2ae045026d04 ro quiet splash
initrd /boot/initrd.img-2.6.32-54-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-54-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,4)'
search --no-floppy --fs-uuid --set 6cc30560-a6f7-449b-bafe-2ae045026d04
echo 'Loading Linux 2.6.32-54-generic ...'
linux /boot/vmlinuz-2.6.32-54-generic root=UUID=6cc30560-a6f7-449b-bafe-2ae045026d04 ro single
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-2.6.32-54-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-53-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,4)'
search --no-floppy --fs-uuid --set 6cc30560-a6f7-449b-bafe-2ae045026d04
linux /boot/vmlinuz-2.6.32-53-generic root=UUID=6cc30560-a6f7-449b-bafe-2ae045026d04 ro quiet splash
initrd /boot/initrd.img-2.6.32-53-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-53-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,4)'
search --no-floppy --fs-uuid --set 6cc30560-a6f7-449b-bafe-2ae045026d04
echo 'Loading Linux 2.6.32-53-generic ...'
linux /boot/vmlinuz-2.6.32-53-generic root=UUID=6cc30560-a6f7-449b-bafe-2ae045026d04 ro single
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-2.6.32-53-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-52-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,4)'
search --no-floppy --fs-uuid --set 6cc30560-a6f7-449b-bafe-2ae045026d04
linux /boot/vmlinuz-2.6.32-52-generic root=UUID=6cc30560-a6f7-449b-bafe-2ae045026d04 ro quiet splash
initrd /boot/initrd.img-2.6.32-52-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-52-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,4)'
search --no-floppy --fs-uuid --set 6cc30560-a6f7-449b-bafe-2ae045026d04
echo 'Loading Linux 2.6.32-52-generic ...'
linux /boot/vmlinuz-2.6.32-52-generic root=UUID=6cc30560-a6f7-449b-bafe-2ae045026d04 ro single
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-2.6.32-52-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-33-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,4)'
search --no-floppy --fs-uuid --set 6cc30560-a6f7-449b-bafe-2ae045026d04
linux /boot/vmlinuz-2.6.32-33-generic root=UUID=6cc30560-a6f7-449b-bafe-2ae045026d04 ro quiet splash
initrd /boot/initrd.img-2.6.32-33-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-33-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,4)'
search --no-floppy --fs-uuid --set 6cc30560-a6f7-449b-bafe-2ae045026d04
echo 'Loading Linux 2.6.32-33-generic ...'
linux /boot/vmlinuz-2.6.32-33-generic root=UUID=6cc30560-a6f7-449b-bafe-2ae045026d04 ro single
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-2.6.32-33-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
insmod ext2
set root='(hd0,4)'
search --no-floppy --fs-uuid --set 6cc30560-a6f7-449b-bafe-2ae045026d04
linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
insmod ext2
set root='(hd0,4)'
search --no-floppy --fs-uuid --set 6cc30560-a6f7-449b-bafe-2ae045026d04
linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
if [ ${timeout} != -1 ]; then
if keystatus; then
if keystatus --shift; then
set timeout=-1
else
set timeout=0
fi
else
if sleep --interruptible 3 ; then
set timeout=0
fi
fi
fi
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###
juicy
2014-01-21 08:58:00 +08:00
andybest
2014-01-21 09:10:12 +08:00
@juicy 谢谢,/etc/default/grub 这个文件中的参数,各种组合我都试了(编辑完执行 sudo update-grub 后重启)

比如:
GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=0

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=false
GRUB_TIMEOUT=0

GRUB_DEFAULT=1
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=3

#GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=3

等等...

我把这几个参数依次改了个遍,但每次重启仍然是停在 GNU GRUB 菜单
这些参数没有起到任何作用...
Esay
2014-01-21 09:16:02 +08:00
额,GITHUB GIST 粘贴一下 /etc/grub.d/10_linux,我可以帮你试着改一下。
andybest
2014-01-21 09:24:42 +08:00
@Esay 谢谢,这个文件好长,并且看起来没有人动过
https://gist.github.com/anonymous/b1688c845d5ced44cffa
Esay
2014-01-21 09:49:07 +08:00
手边也没有Linux,不能帮你试试。

1.
130 行改为
if [ "x$list" != "x" ] ; then

2.
165 行改为
fi

3.
/boot/grub/grub.cfg 里加上 GRUB_DISABLE_LINUX_RECOVERY=true

4. sudo update-grub

我也是猜着改的,应该只留下一个选项了。你试下吧,看下啥结果。
andybest
2014-01-21 09:59:05 +08:00
@Esay 谢谢。。但我 VPS 上有重要的数据,真是不太敢改怕启动不起来了
我看其他同样配置的 VPS 的 /etc/grub.d/10_linux 并没有这样的改动,
为什么就这一台会出现这种问题(/etc/default/grub不生效)

就是为什么与同配置的其他机器
/etc/default/grub
/boot/grub/grub.cfg
/etc/grub.d/10_linux
这三个文件完全一致,这台机器重启会停在 GRUB 而其他机器不会

并不是一定要用各种手段隐藏掉 GRUB 选择界面,而是想知道知道为什么,从而解决。
谢谢
Esay
2014-01-21 10:03:41 +08:00
@andybest 呃,猜测是
1.重新安装的 GRUB 版本和原来的不一样。
2.其他的 Ubuntu 没有升级过内核。
Ansen
2014-01-21 10:35:25 +08:00
试试让系统重新生成/boot/grub/grub.cfg
#update-grub
harmy
2014-01-21 12:59:44 +08:00
sudo vim /etc/default/grub

添加这行:
GRUB_RECORDFAIL_TIMEOUT=2

然后再:
sudo update-grub
andybest
2014-01-22 01:32:02 +08:00
@Ansen 谢谢,重新生成并重启了,但还是卡在 GRUB 选择菜单没有效果:

# ls /boot/grub/grub.cfg -l
-r--r--r-- 1 root root 2681 Jan 21 09:20 /boot/grub/grub.cfg
#
#
# grub-mkconfig -o /boot/grub/grub.cfg
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.32-49-generic-pae
Found initrd image: /boot/initrd.img-2.6.32-49-generic-pae
Found memtest86+ image: /boot/memtest86+.bin
done
# ls /boot/grub/grub.cfg -l
-r--r--r-- 1 root root 2681 Jan 22 01:25 /boot/grub/grub.cfg
# date
Wed Jan 22 01:25:16 CST 2014

# update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.32-49-generic-pae
Found initrd image: /boot/initrd.img-2.6.32-49-generic-pae
Found memtest86+ image: /boot/memtest86+.bin
done
# sudo update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.32-49-generic-pae
Found initrd image: /boot/initrd.img-2.6.32-49-generic-pae
Found memtest86+ image: /boot/memtest86+.bin
done
#

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/97787

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX