snapfsck.bash
changeset 5 fdaedf474996
parent 4 0565633d7bfa
equal deleted inserted replaced
4:0565633d7bfa 5:fdaedf474996
    52 
    52 
    53 d=$(date +%Y%m%d%H%M%S)
    53 d=$(date +%Y%m%d%H%M%S)
    54 lvcreate -n"$lvs" -L"$SNAPSIZE" -s "$vg/$lv" || die
    54 lvcreate -n"$lvs" -L"$SNAPSIZE" -s "$vg/$lv" || die
    55 if e2fsck -fp "/dev/$vg/$lvs"; then
    55 if e2fsck -fp "/dev/$vg/$lvs"; then
    56     tune2fs -C 1 -T "$d" "/dev/$vg/$lv" || die
    56     tune2fs -C 1 -T "$d" "/dev/$vg/$lv" || die
    57     # removing /dev/$vg/snap.$lv or just $vg/snap.$lv does not work reliably
       
    58     # removing /dev/mapper/$vg-snap.$lv does not work reliably either nor does
       
    59     # the workaround suggested at
       
    60     # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=549691#57
       
    61     waittime=1 # second
    57     waittime=1 # second
    62     tries=60
    58     tries=60
    63     i=1
    59     i=1
    64     until lvremove -f "$vg/$lvs"; do
    60     # if you have problems removing volumes then you may have the 'udisks'
    65         if [ $i -lt $tries ]; then
    61     # package installed; see:
    66             warn retrying snapshot removal
    62     # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=549691#74
    67             sleep $waittime
    63     # https://bugzilla.redhat.com/show_bug.cgi?id=577798#c5
    68             i=$((i+1))
    64     # https://www.redhat.com/archives/linux-lvm/2010-August/msg00029.html
    69         else
    65     lvremove -f "$vg/$lvs" || die
    70             die giving up snapshot removal
       
    71         fi
       
    72     done
       
    73 else
    66 else
    74     die fsck returned nonzero: this may indicate filesystem corruption on the origin volume. The snapshot has not been removed.
    67     die fsck returned nonzero: this may indicate filesystem corruption on the origin volume. The snapshot has not been removed.
    75 fi
    68 fi