gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 16:44:03 25 4
gpt4 key购买 nike

我在单板计算机上有一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com