如何在启动时自动响应fsck提示

Nat*_*hek 10 filesystems ubuntu

我在单板计算机上有一个ubuntu服务器(11.10),偶尔可能会被关闭.当它在之后启动时,fsck会提示用户按'f'来检查驱动器.因为这个服务器通常没有连接监视器和键盘,并且正常访问它的唯一方法是通过SSH,这非常不方便.

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

谢谢!

Nat*_*hek 10

所以我找到了两个相关的问题解决方案:

我不确定这些是否在所有地方都有效,但它们适用于ubuntu服务器11.10.

/ etc/default/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
Run Code Online (Sandbox Code Playgroud)

确保最后一行代替读取

# automatically repair filesystems with inconsistencies during boot
FSCKFIX=yes
Run Code Online (Sandbox Code Playgroud)

系统刚刚启动而不需要用户干预的另一个障碍是grub bootloader屏幕在启动失败/中断后等待用户输入.

这需要编辑/etc/grub.d/00_header中的grub设置文件

/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-}
Run Code Online (Sandbox Code Playgroud)

只需将第236行更改为

set timeout = 0
Run Code Online (Sandbox Code Playgroud)

和238行到

set timeout = 0
Run Code Online (Sandbox Code Playgroud)

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