如何强制 ubuntu 在启动时修复根目录而不与用户交互?

如何强制 ubuntu 在启动时修复根目录而不与用户交互?

我在工业主板上使用 ubuntu(比格犬骨黑色)。有时由于电源故障或其他问题,启动时操作系统会要求按 F 键修复根分区并等待用户执行某些操作。但我想确保操作系统启动,因为那里没有用户可以按任何按钮,实际上没有串行电缆连接到我的嵌入式主板,因此任何人都可以向其发送任何字符。

如何配置 ubuntu 以便它总是修复文件系统而不询问用户?

答案1

使用-a論點。

fsck /dev/sdaX -a -p

$ man fsck

摘自手册页:

   Options  to  different filesystem-specific fsck's are not standardized.
   If in doubt, please consult the man pages  of  the  filesystem-specific
   checker.   Although not guaranteed, the following options are supported
   by most filesystem checkers:

   -a     Automatically repair the filesystem without any  questions  (use
          this  option with caution).  Note that e2fsck(8) supports -a for
          backward compatibility only.  This option is mapped to  e2fsck's
          -p  option  which is safe to use, unlike the -a option that some
          filesystem checkers support.

   -n     For some filesystem-specific checkers, the -n option will  cause
          the fs-specific fsck to avoid attempting to repair any problems,
          but simply report such problems to stdout.  This is however  not
          true  for  all  filesystem-specific  checkers.   In  particular,
          fsck.reiserfs(8) will not report any corruption  if  given  this
          option.  fsck.minix(8) does not support the -n option at all.

   -r     Interactively  repair  the  filesystem  (ask for confirmations).
          Note: It is generally a bad idea to use this option if  multiple
          fsck's  are  being  run  in  parallel.   Also  note that this is
          e2fsck's default behavior; it supports this option for  backward
          compatibility reasons only.

   -y     For  some filesystem-specific checkers, the -y option will cause
          the fs-specific fsck to  always  attempt  to  fix  any  detected
          filesystem corruption automatically.  Sometimes an expert may be
          able to do better driving the fsck manually.  Note that not  all
          filesystem-specific checkers implement this option.  In particu‐
          lar fsck.minix(8) and  fsck.cramfs(8)  do  not  support  the  -y
          option as of this writing.

快速帮助屏幕显示:

Emergency help:
 -p                   Automatic repair (no questions)
 -n                   Make no changes to the filesystem
 -y                   Assume "yes" to all questions
 -c                   Check for bad blocks and add them to the badblock list
 -f                   Force checking even if filesystem is marked clean
 -v                   Be verbose
 -b superblock        Use alternative superblock
 -B blocksize         Force blocksize when looking for superblock
 -j external_journal  Set location of the external journal
 -l bad_blocks_file   Add to badblocks list
 -L bad_blocks_file   Set badblocks list

其他相关项目:

调用/etc/fstab进行/etc/init.d/checkfs.sh检查。您可以编辑该文件以为其提供所需的参数。

检查这些块:

[ "$fscheck" = yes ] && log_warning_msg "Fast boot enabled, so skipping file system check."

if [ "$fscheck" = yes ] && [ ! "$BAT" ] && [ "$FSCKTYPES" != "none" ]

相关内容