]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blob - contrib/e2croncheck
mke2fs: fix permissions setting with "mke2fs -d /path/files"
[thirdparty/e2fsprogs.git] / contrib / e2croncheck
1 #!/bin/sh
2 #
3 # e2croncheck -- run e2fsck automatically out of /etc/cron.weekly
4 #
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).
10 #
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
14 #
15 # Written by Theodore Ts'o, Copyright 2007, 2008, 2009.
16 #
17 # This file may be redistributed under the terms of the
18 # GNU Public License, version 2.
19 #
20
21 VG=ssd
22 VOLUME=root
23 SNAPSIZE=100m
24 EMAIL=sysadmin@example.com
25
26 TMPFILE=`mktemp ${TMPDIR:-/tmp}/e2fsck.log.XXXXXXXXXX`
27
28 OPTS="-Fttv -C0"
29 #OPTS="-Fttv -E fragcheck"
30
31 set -e
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}"
38 else
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
43 fi
44 fi
45 lvremove -f "${VG}/${VOLUME}-snap"
46 rm $TMPFILE
47