From 123a5dff987469250391a65738f0d0936ecff43f Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Wed, 18 Dec 2002 07:21:31 +0000 Subject: [PATCH] Delay an optional amount of time after booting before starting a background fsck. The delay defaults to sixty seconds to allow large applications such as the X server to start before disk I/O bandwidth is monopolized by fsck. Submitted by: Brooks Davis Sponsored by: DARPA & NAI Labs. --- etc/defaults/rc.conf | 1 + etc/rc | 10 ++++++++-- etc/rc.d/bgfsck | 15 +++++++++++++-- share/man/man5/rc.conf.5 | 5 +++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf index 954bfa830e2f..791d2cd53d3b 100644 --- a/etc/defaults/rc.conf +++ b/etc/defaults/rc.conf @@ -40,6 +40,7 @@ script_name_sep=" " # Change if your startup scripts' names contain spaces rc_conf_files="/etc/rc.conf /etc/rc.conf.local" fsck_y_enable="NO" # Set to YES to do fsck -y if the initial preen fails. background_fsck="YES" # Attempt to run fsck in the background where possible. +background_fsck_delay="60" # Time to wait (seconds) before starting the fsck. extra_netfs_types="NO" # List of network extra filesystem types for delayed # mount at startup (or NO). diff --git a/etc/rc b/etc/rc index 20a841419896..636fdbc6af7a 100644 --- a/etc/rc +++ b/etc/rc @@ -982,8 +982,14 @@ esac # Start background fsck checks if necessary case ${background_fsck} in [Yy][Ee][Ss]) - echo 'Starting background filesystem checks' - nice -4 fsck -B -p 2>&1 | logger -p daemon.notice & + bgfsck_msg='Starting background file system checks' + if [ ${background_fsck_delay:=0} -gt 0 ]; then + bgfsck_msg="${bgfsck_msg} in ${background_fsck_delay} seconds" + fi + echo "${bgfsck_msg}." + + (sleep ${background_fsck_delay}; nice -4 fsck -B -p) 2>&1 | \ + logger -p daemon.notice & ;; esac diff --git a/etc/rc.d/bgfsck b/etc/rc.d/bgfsck index f03247386702..86c26d3a1791 100644 --- a/etc/rc.d/bgfsck +++ b/etc/rc.d/bgfsck @@ -11,9 +11,20 @@ name="background-fsck" rcvar="background_fsck" -start_precmd="echo 'Starting background file system checks.'" -start_cmd="nice -4 fsck -B -p 2>&1 | logger -p daemon.notice &" +start_cmd="bgfsck_start" stop_cmd=":" +bgfsck_start () +{ + bgfsck_msg='Starting background file system checks' + if [ ${background_fsck_delay:=0} -gt 0 ]; then + bgfsck_msg="${bgfsck_msg} in ${background_fsck_delay} seconds" + fi + echo "${bgfsck_msg}." + + (sleep ${background_fsck_delay}; nice -4 fsck -B -p) 2>&1 | \ + logger -p daemon.notice & +} + load_rc_config $name run_rc_command "$1" diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index fb758f9f9ac6..a49f9d9024eb 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -734,6 +734,11 @@ If set to the system will attempt to run .Xr fsck 8 in the background where possible. +.It Va background_fsck_delay +.Pq Vt int +The amount of time in seconds to sleep before starting a background fsck. +It defaults to sixty seconds to allow large applications such as +the X server to start before disk I/O bandwidth is monopolized by fsck. .It Va extra_netfs_types .Pq Vt str If set to something other than