diff -r a2875a6fd7b2 -r 577954f4f887 snapfsck.sh --- a/snapfsck.sh Tue May 08 11:36:14 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -#!/bin/bash - -set -e - -SNAPSIZE='500M' - -warn() { - echo $@ >&2 -} - -die() { - if [ $# -ne 0 ]; then - echo $@ >&2 - else - echo something went wrong - fi - exit 1 -} - -usage() { - -cat <<__U -usage: - $0 [-s snapsize] /dev// - or - $0 [-s snapsize] / - but not (yet?) - $0 [-s snapsize] /dev/mapper/- -__U - -exit 1 - -} - -cleanup() { - - # if you have problems removing volumes then you may have the 'udisks' - # package installed; see: - # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=549691#74 - # https://bugzilla.redhat.com/show_bug.cgi?id=577798#c5 - # https://www.redhat.com/archives/linux-lvm/2010-August/msg00029.html - lvs "$vg/$lvs" && lvremove -f "$vg/$lvs" - -} - -while getopts "s:" opt; do - case $opt in - s) - SNAPSIZE="$OPTARG" - ;; - \?) - usage - ;; - esac -done -shift $((OPTIND-1)) - -p=${1:?device required} -p=${p#/dev/} -vg=${p%/*} -lv=${p##*/} -lvs="snap.${lv}" - -trap cleanup EXIT - -[ -n "${vg}" -a -n "${lv}" -a "${vg}" != "${p}" -a "${lv}" != "${p}" ] || usage - -d=$(date +%Y%m%d%H%M%S) -lvcreate -n"$lvs" -L"$SNAPSIZE" -s "$vg/$lv" -# fix any noncritical problems automatically and don't make any noise (on -# stderr) about it; note that these problems remain present on the origin -# volume -e2fsck -fp "/dev/$vg/$lvs" 2>&1 || true -if e2fsck -fy "/dev/$vg/$lvs" 2>&1; then - tune2fs -C 1 -T "$d" "/dev/$vg/$lv" -else - die fsck returned nonzero: this may indicate filesystem corruption on the origin volume. -fi