Craig Sanders <[email protected]> writes:
> On Tue, Nov 06, 2012 at 02:05:25PM +1100, Jason White wrote:
>> Andrew Worsley <[email protected]> wrote:
>> > Is there any tool that will unmount a filesystem and fsck say once
>> > every 2-3 months to avoid having the
>> > massive slow fsck on the reboot every 6-12 months?
Use a journalled filesystem.
>> I avoid the problem altogether by not using ext2/3/4 as my file system.
That's an integrity check. You can skip if it you really want to:
> tune2fs -i 0 -c 0 /dev/xxxx
>> The Cron job might be your easiest solution.
I tried this, but it whinges constantly about leaking fds, because lvm
is stupid. I haven't gotten around to cleaning it up.
$ cat /etc/cron.weekly/avoid-fsck
#!/bin/bash
## e2fsck is usually triggers after enough mounts, or enough time
## without a fsck. For always-on servers, the latter usually means
## that after an outage, you have to wait a few hours for the fscks to
## finish before normal operation resumes. This is especially
## annoying as it cannot be skipped on Ubuntu 10.04 servers.
##
## Instead we make an LVM snapshot of each ext LV, and if *that* fscks
## OK, we conclude that there were no errors and we set the snapshot's
## origin to indicate that a fsck has taken place.
# Boilerplate prelude ################################################
set -eEu
set -o pipefail
trap 'echo >&2 "$0: unknown error"' ERR
while getopts d opt
do case "$opt" in (d) set -x;; ('?') exit 1;; esac
done
shift $((${OPTIND:-1}-1))
# Begin code #########################################################
# Silently succeed if the necessary tools aren't available, as that
# strongly indicates this script is not needed on this host.
{ which lvs && which tune2fs; } &>/dev/null || exit 0
# Output of e2fsck is desirable iff e2fsck had a genuine issue. It
# may be arbitrarily long, so a temporary file is more appropriate
# than a simple bash variable.
f="`mktemp -t avoid-fsck.XXXXXX`"
trap 'rm -f "$f"' EXIT
#lvs | sed 1d | grep '[-o]wi-ao' | # list of LVs (FIXME: dodgy regex).
lvs --noheadings --separator , --options lv_name,vg_name,origin |
while IFS="$IFS," read lv vg origin
do
# Skip snapshots.
test -z "$origin" || continue
# Skip non-ext LVs.
tune2fs -l "/dev/$vg/$lv" &>/dev/null || continue
# Cleanup any mess left over from a previous run.
test ! -e "/dev/$vg/fsck_$lv" ||
>/dev/null lvremove -f "/dev/$vg/fsck_$lv"
# NB: 4G should be plenty of space for the COW, since we are only
# going to keep it around long enough to do a fsck.
>/dev/null lvcreate --snapshot "/dev/$vg/$lv" --name "fsck_$lv" --size
4G
if nice ionice -c3 e2fsck -p "/dev/$vg/fsck_$lv" >"$f" ||
test $? -eq 1 -o $? -eq 4 -o $? -eq 5 # Ignore "safe" statuses.
then
>/dev/null tune2fs -C0 -Tnow "/dev/$vg/$lv"
else
>&2 echo "e2fsck -p /dev/$vg/fsck_$lv failed"
>&2 cat "$f"
fi
>/dev/null lvremove -f "/dev/$vg/fsck_$lv"
done
_______________________________________________
luv-main mailing list
[email protected]
http://lists.luv.asn.au/listinfo/luv-main