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

标签 ubuntu filesystems

我在单板计算机上有一个 ubuntu 服务器 (11.10),偶尔会意外断电。之后启动时,fsck 会提示用户按“f”来检查驱动器。因为这个服务器一般不接显示器和键盘,正常访问只能通过SSH,非常不方便。

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

谢谢!

最佳答案

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

我不确定这些在任何地方都有效,但它们适用于 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

确保最后一行改为

# automatically repair filesystems with inconsistencies during boot
FSCKFIX=yes

系统在不需要用户干预的情况下始终启动的另一个障碍是 grub 引导加载程序屏幕在引导失败/中断后等待用户输入。

这需要编辑 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 更新 grub 获取/boot/grub/grub.cfg 文件中实现的更改。

关于ubuntu - 如何在启动时自动响应 fsck 提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9932250/

相关文章:

objective-c - 如何使用 Objective C 访问特定的 iOS 应用程序目录?

linux-kernel - 在 Linux 中,每个文件系统有多少个 super block ?

linux - 在 Linux 中编译 C++

ubuntu - 如何在 Ubuntu 机器上安装 TortoiseSVN 存储库?

ubuntu - NVIDIA Jetson 无法识别 EasyCap USB 摄像头

Python fnmatch,检查存在的文件

ubuntu - 无法将 solc 链接到 Geth

ruby-on-rails - sudo gem install pg 不起作用

c++ - 创建一个 "mountable"文件系统,从哪里开始?

asynchronous - vertx 3 在执行一系列 vertex.fileSytem 操作时避免嵌套 Handler<AsyncResult>