#!/bin/sh # # e2croncheck --- put this in your weekly crontab # # make sure you customize "VG" so it is your LVM # volume group name, # "VOLUME" so it is the name of the root logical volume, and "EMAIL" to # be your e-mail address # # Written by Theodore Ts'o, Copyright 2007-2008 # # This file may be redistributed under the terms of the # GNU Public License, version 2. # VG=ssd VOLUME=root SNAPSIZE=100m EMAIL=tytso@mit.edu TMPFILE=`mktemp -t e2fsck.log.XXXXXXXXXX` OPTS="-Fttv -C0" #OPTS="-Fttv -E fragcheck" set -e START="$(date +'%Y%m%d%H%M%S')" lvcreate -s -L ${SNAPSIZE} -n "${VOLUME}-snap" "${VG}/${VOLUME}" if nice logsave -as $TMPFILE e2fsck -p $OPTS "/dev/${VG}/${VOLUME}-snap" && \ nice logsave -as $TMPFILE e2fsck -fy $OPTS "/dev/${VG}/${VOLUME}-snap" ; then echo 'Background scrubbing succeeded!' tune2fs -C 0 -T "${START}" "/dev/${VG}/${VOLUME}" else echo 'Background scrubbing failed! Reboot to fsck soon!' tune2fs -C 16000 -T "19000101" "/dev/${VG}/${VOLUME}" if test -n "$RPT-EMAIL"; then mail -s "E2fsck of /dev/${VG}/${VOLUME} failed!" $EMAIL < $TMPFILE fi fi lvremove -f "${VG}/${VOLUME}-snap" rm $TMPFILE