2012-03-29 17 views
9

我的单板计算机上有一台Ubuntu服务器(11.10),偶尔会出现意外断电的情况。之后启动时,fsck会提示用户点击'f'来检查驱动器。由于该服务器通常没有连接监视器和键盘,并且通常只能通过SSH访问它,这非常不方便。如何在启动时自动响应fsck提示

有没有办法保证启动时可以在没有用户输入的情况下完成任何所需的fsck检查?基本上,我希望它在启动时(当检测到问题时)始终运行'fsck -y',而不是提示用户输入。

谢谢!

+0

-a:自动修复文件系统时没有任何问题(谨慎使用此选项)。请注意,e2fsck(8)仅支持-a以实现向后兼容。这个选项映射到e2fsck的-p选项,这是安全的,与大多数文件系统检查程序支持的-a选项不同。 – tawman 2012-03-29 19:40:42

+0

我在哪里添加-a选项?我没有自己运行fsck,ubuntu服务器在启动时自动运行它。 – 2012-03-29 20:19:02

+0

unbuntu服务器将只运行一个init.d脚本。我的unbuntu虚拟机已关闭atm,但您可以找到哪个启动脚本正在运行fsck并添加该选项 – tawman 2012-03-29 21:05:44

回答

10

所以我发现我的问题,有两种相关的解决方案:

我不知道这是放之四海而皆准的,但他们的Ubuntu 11.10服务器上运行。

的/ etc /默认/ RCS是这样的:

# 
# /etc/default/rcS 
# 
# Default settings for the scripts in /etc/rcS.d/ 
# 
# For information about these variables see the rcS(5) manual page. 
# 
# This file belongs to the "initscripts" package. 

# delete files in /tmp during boot older than x days. 
# '0' means always, -1 or 'infinite' disables the feature 
TMPTIME=0 

# spawn sulogin during boot, continue normal boot if not used in 30 seconds 
SULOGIN=no 

# do not allow users to log in until the boot has completed 
DELAYLOGIN=no 

# assume that the BIOS clock is set to UTC time (recommended) 
UTC=yes 

# be more verbose during the boot process 
VERBOSE=no 

# automatically repair filesystems with inconsistencies during boot 
FSCKFIX=no 

请确保最后一行,而不是读

# automatically repair filesystems with inconsistencies during boot 
FSCKFIX=yes 

另一个障碍,我不得不刚刚启动总是无需用户干预的系统在启动失败/中断后,grub bootloader屏幕正在等待用户输入。

这就要求编辑在 grub的安装文件/etc/grub.d/00_header

/etc/grub.d$ grep -r -n -C3 timeout ./ 
./00_header-229- fi 
./00_header-230-fi 
./00_header-231- 
./00_header:232:make_timeout() 
./00_header-233-{ 
./00_header-234- cat << EOF 
./00_header-235-if [ "\${recordfail}" = 1 ]; then 
./00_header:236: set timeout=-1 
./00_header-237-else 
./00_header:238: set timeout=${2} 
./00_header-239-fi 
./00_header-240-EOF 
./00_header-241-} 

简单地改变行236

set timeout = 0 

和线路238

set timeout = 0 

这会导致系统在启动时不会暂停。编辑文件后,运行 sudo update-grub 以获取在/boot/grub/grub.cfg文件中实施的更改。

3

GRUB的,而不是如上述文件修修补补,如果你使用的是最新版本的GRUB是GRUB2的,清洁的方法是:

变化“的/ etc /默认/平头” 添加行GRUB_RECORDFAIL_TIMEOUT="30" 然后运行update-grub

相关问题