3 # e2croncheck -- run e2fsck automatically out of /etc/cron.weekly
5 # This script is intended to be run by the system administrator
6 # periodically from the command line, or to be run once a week
7 # or so by the cron daemon to check a mounted filesystem (normally
8 # the root filesystem, but it could be used to check other filesystems
9 # that are always mounted when the system is booted).
11 # Make sure you customize "VG" so it is your LVM volume group name,
12 # "VOLUME" so it is the name of the filesystem's logical volume,
13 # and "EMAIL" to be your e-mail address
15 # Written by Theodore Ts'o, Copyright 2007, 2008, 2009.
17 # This file may be redistributed under the terms of the
18 # GNU Public License, version 2.
24 EMAIL
=sysadmin@example.com
26 TMPFILE
=`mktemp -t e2fsck.log.XXXXXXXXXX`
29 #OPTS="-Fttv -E fragcheck"
32 START
="$(date +'%Y%m%d%H%M%S')"
33 lvcreate
-s -L ${SNAPSIZE} -n "${VOLUME}-snap" "${VG}/${VOLUME}"
34 if nice logsave -as $TMPFILE e2fsck -p $OPTS "/dev
/${VG}/${VOLUME}-snap" && \
35 nice logsave -as $TMPFILE e2fsck -fy $OPTS "/dev
/${VG}/${VOLUME}-snap" ; then
36 echo 'Background scrubbing succeeded!'
37 tune2fs -C 0 -T "${START}" "/dev/${VG}/${VOLUME}"
39 echo 'Background scrubbing failed! Reboot to fsck soon!'
40 tune2fs -C 16000 -T "19000101" "/dev
/${VG}/${VOLUME}"
41 if test -n "$RPT-EMAIL"; then
42 mail -s "E2fsck of
/dev
/${VG}/${VOLUME} failed
!" $EMAIL < $TMPFILE
45 lvremove -f "${VG}/${VOLUME}-snap"