[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Lots of lost+found files ...



On Dec 13, 2001  14:57 -0700, Andreas Dilger wrote:
> Probably the basics of such a system would look like (untested):

OK, here is a version that actually runs and appears to work on my system.
It only shows the e2fsck output (LVM stuff is a bit too verbose for me).

Cheers, Andreas
==================== (/usr/local/sbin/lvm-e2fsck.sh) ======================
#!/bin/sh
# Automatically checks ext2/ext3 filesystems that are currently mounted
# and also residing on LVM logical volumes, so that we can snapshot them.
# You need to have the LVM VFS locking patch applied for this to work.
#
# (C) Andreas Dilger, 2001
#
# Licensed under the GNU General Public License, version 2 or later

#set -vx

FSCKLV=lve2fsck
lvscan | awk '/ACTIVE/ { print $4 }' | tr -d \" | while read LV; do
	VG="`dirname $LV`"
	LVS="$VG/$FSCKLV"
	# This could be smarter, but we don't want to do concurrent fscks if
	# it takes a really long time to run, or if the script has problems.
	[ "$LV" = "$LVS" ] && echo "$LVS exists!" && exit 1
	mount | grep -q "$LV.*ext[23]" || continue

	# Just a guess at how much snapshot space we need
	SIZE="`df $LV | tail +2 | awk '{ print $2 / 500 }'`"
	lvcreate -s -L ${SIZE}k -n $FSCKLV $LV > /dev/null
	rc=$?
	if [ $rc -ne 0 ]; then
		echo "Creating snapshot of $LV at $LVS failed with rc=$rc" 1>&2
		continue
	fi
	e2fsck -f -n $LVS
	rc=$?
	if [ $rc -ne 0 ]; then
		echo "e2fsck of $LV snapshot failed with rc=$rc" 1>&2
	else
		tune2fs -C 0 $LV > /dev/null
	fi
	lvremove -f $LVS > /dev/null
	rc=$?
	[ $rc -ne 0 ] && echo "lvremove of $LVS failed with rc=$rc" 1>&2
done
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]