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

Re: Lots of lost+found files ...

On Dec 13, 2001  15:46 -0500, Bill Rugolsky Jr. wrote:
> On Thu, Dec 13, 2001 at 12:28:37PM -0700, Andreas Dilger wrote:
> > And why disabling both the per-mount and time-based e2fscks is a bad idea.
> Which is fine if you have small drives and reboot often.  But with my
> laptop, which I do boot at least once per day, the fsck time 
> is quite annoying.  (But I do it anyway, since laptop IDE configurations
> are often dodgy.) Ideally one would simply cron a periodic LVM snapshot and
> background fsck.

Well, you can always change the mounts/time interval with which e2fsck
checks filesystems, but as you say, laptops seem to have the most problems
with this.

I have tested the LVM-snapshot+e2fsck method and it works well, although
I do not have an all-LVM system so that is not very useful.  What
would be nice is if you also update the mount-count and last-checked
fields on the original device, so that you know the filesystem was
recently checked.  That would mean the check intervals would continue
to work properly (in case your cron script fails or is never run if
your system is always off when it would be run), but in normal cases
you would never see a fsck at boot again.

You can set the mount count with "tune2fs -C 0 /dev/foo", but not the
last checked time.  It is possible with "debugfs" but not terribly easy.
Ted, what do you think about adding an (undocumented maybe) option to
tune2fs which allows special-purpose tools like this to set the last
checked time of the filesystem?  Maybe "-I" to match the "-i" flag,
like "-c" and "-C" do?

Probably the basics of such a system would look like (untested):

# 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

lvscan | awk '/ACTIVE/ { print $4 }' | while read LV; do
	VG="`dirname $LVPATH`"
	# 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
	if [ $rc -ne 0 ]; then
		echo "Creating snapshot of $LV at $LVS failed with rc=$rc" 1>&2
	e2fsck -f -n $FSCKLV
	if [ $? -ne 0 ]; then
		echo "e2fsck of $LV snapshot failed with rc=$rc" 1>&2
	lvremove -f $FSCKLV
	if [ $? -ne 0 ]; then
		echo "lvremove of $LVS failed with rc=$rc" 1>&2
	tune2fs -C 0 $LV
	echo "e2fsck of $LV completed successfully"

Cheers, Andreas
Andreas Dilger

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