LinHES Forums
http://forums.linhes.org/

set e2fsck to scan on next boot?
http://forums.linhes.org/viewtopic.php?f=5&t=20163
Page 1 of 1

Author:  neutron68 [ Sun Jul 19, 2009 12:08 pm ]
Post subject:  set e2fsck to scan on next boot?

A friend told me that the e2fsck program could be set to scan your hard disk partitions on the next boot. He said it sets a flag to force a scan on the next boot of the system - before the partitions are mounted by the system.

http://man.linuxmanpages.com/man8/e2fsck.8.php

I just looked over the man page for e2fsck and don't see any references to forcing a scan on the next reboot.

Is my friend wrong?

Author:  tjc [ Sun Jul 19, 2009 12:24 pm ]
Post subject: 

No, he's right. You can even get shutdown to trigger it using the "-F" flag if memory serves.

Now if I could just remember how to delay it so when I'm doing testing it doesn't trigger every 32 boots (that goes by really fast sometimes). ;-)

BTW - Thanks for reminding me to look this up, tune2fs is the utility that lets you fiddle these params.

Author:  neutron68 [ Sun Jul 19, 2009 1:05 pm ]
Post subject:  any idea which switch?

Do you see any of the e2fsck switches that look like they would force the scan on next boot? None look obvious to me.

Appreciated,
Eric

Author:  graysky [ Sun Jul 19, 2009 2:51 pm ]
Post subject: 

Code:
# shutdown -rF now


From the shutdown man page:

Quote:
The -F flag means `force fsck'. This only creates an advisory file /forcefsck which can be tested by the system when it comes up again. The boot rc file can test if this file is present, and decide to run fsck(1) with a special `force' flag so that even properly unmounted filesystems get checked. After that, the boot process should remove /forcefsck.


Alternatively, you can Login as the root, change directory to root (/) directory and manually create that empty file named forcefsck (source for that little trick).:

Code:
 $ su -
# cd /
# touch /forcefsck

Author:  neutron68 [ Sun Jul 19, 2009 3:10 pm ]
Post subject:  all partitions?

Any idea if
Code:
# shutdown -rF now
will force a scan of all partitions - specifically the /myth partition (/dev/sda3)?

Author:  graysky [ Sun Jul 19, 2009 4:12 pm ]
Post subject: 

I believe it will run through all the partitions in your /etc/fstab assuming you haven't set them to 0 in the 6th column (pass or fsck options).

Code:
# /etc/fstab: static file system information
#
# <file system>        <dir>         <type>    <options>          <dump> <pass>
none                   /dev/pts      devpts    defaults            0      0
none                   /dev/shm      tmpfs     defaults            0      0

LABEL=Arch   /       ext4    defaults,noatime     0       1
LABEL=Homes   /home   ext4    defaults,noatime     0       2
LABEL=Data   /media/data        ntfs-3g defaults,noatime        0       0
/dev/sda5   swap    swap    defaults        0       0
/dev/dvd   /media/dvd  auto    ro,user,noauto,unhide   0      0

Author:  neutron68 [ Mon Jul 20, 2009 7:02 pm ]
Post subject:  it worked - scan ran

This is a scan of sda3 - the /myth partition.
Does 13% fragmentation seem like a lot?

Code:
Log of fsck -C -R -A -a -f
Mon Jul 20 19:24:54 2009

fsck 1.40.6 (09-Feb-2008)
/dev/sda3: 2124/121241600 files (13.2% non-contiguous), 162771377/242477077 blocks

Mon Jul 20 19:47:11 2009

Author:  graysky [ Tue Jul 21, 2009 1:52 pm ]
Post subject:  Re: it worked - scan ran

neutron68 wrote:
This is a scan of sda3 - the /myth partition.
Does 13% fragmentation seem like a lot?

Code:
Log of fsck -C -R -A -a -f
Mon Jul 20 19:24:54 2009

fsck 1.40.6 (09-Feb-2008)
/dev/sda3: 2124/121241600 files (13.2% non-contiguous), 162771377/242477077 blocks

Mon Jul 20 19:47:11 2009


In my mind, yeah it does seem like too much. Others may disagree.

What is the file system of /dev/sda3? Ext3 or...? Unless it's XFS, I don't think you can use a defragger on it (ext2/ext3 for example). Have a look at this howto for more on XFS and XFS defragging. There is also a section in the howto with info that should help you avoid future fragmentation, but as file systems age, they also become fragmented (so long as they are being used as they age). If you have less than 20 % free space, this too can contribute to fragmentation.

You can defrag an ext3 partition if you literally copy all the files off it, reformat it, and copy them back. If you're gonna go through the trouble of doing that, you might as well use a filesystem designed for large files (XFS) and one that has an online defragger :)

Your other option is to just leave it and wait for R6 to go final. The 2.6.29 and above kernel support ext4 which is rumored to have an online defragger although as of right now as I write this reply, no such util is stable to my knowledge.

Author:  neutron68 [ Tue Jul 21, 2009 4:33 pm ]
Post subject:  /myth is ext3

The /myth partition is ext3. The 1TB drive is about 70% full.

I record and delete about 2GB a day.

I started wondering about fragmentation, when I saw a standard definition recording being made a week or 2 ago, and the hard drive access LED was blinking more rapidly than it used to do during a standard definition recording, from the PVR-150 card. With standard definition recordings, the hard drive light used to blink maybe 1 time per second. Now it is more like 5 times per second. This has become a trend, so I suspected fragmentation.

Eric

Author:  graysky [ Wed Jul 22, 2009 1:34 pm ]
Post subject:  Re: it worked - scan ran

Probably best to switch to XFS in your situation...

graysky wrote:
Have a look at this howto for more on XFS and XFS defragging. There is also a section in the howto with info that should help you avoid future fragmentation, but as file systems age, they also become fragmented (so long as they are being used as they age). If you have less than 20 % free space, this too can contribute to fragmentation.

Author:  turpie [ Wed Jul 22, 2009 8:12 pm ]
Post subject: 

tjc wrote:
No, he's right. You can even get shutdown to trigger it using the "-F" flag if memory serves.

Now if I could just remember how to delay it so when I'm doing testing it doesn't trigger every 32 boots (that goes by really fast sometimes). ;-)

BTW - Thanks for reminding me to look this up, tune2fs is the utility that lets you fiddle these params.


Does anyone know of an easy way to skip fsck on a the current boot?
I can hit control-c but then it doesn't mount the partition and I still can't use the system. Apparently on Ubuntu you can hit escape to delay it until the next boot, does this work on Knoppmyth? (I read this after it had already done the scan.)
If there isn't something as simple as a keypress I will add an option to the Knoppmyth menu to "Reboot without fsck." so that I can at least shorten the process a bit.

Author:  cliffsjunk [ Thu Jul 23, 2009 9:06 am ]
Post subject: 

turpie wrote:
Does anyone know of an easy way to skip fsck on a the current boot?
I can hit control-c but then it doesn't mount the partition and I still can't use the system.

Google says we used to do this in Ubuntu before they added it to the distro:

See man e2fsck.conf(5). Create a file /etc/e2fsck.conf, with the
contents:

[options]
allow_cancellation = true

Then you should be able to type ^C while it is doing a check, and
cancel the fsck. (It is safe to abort fsck while it is scanning the
filesystem.)

Author:  cliffsjunk [ Thu Jul 23, 2009 9:14 am ]
Post subject:  Re: all partitions?

neutron68 wrote:
Any idea if
Code:
# shutdown -rF now
will force a scan of all partitions - specifically the /myth partition (/dev/sda3)?


To force a scan on a particular partition use:
Code:
tune2fs -C 9999 /dev/sda3


This assumes that you have a scan set up for every say 30 mounts. It sets the current mount count to 9999. If you have tweaked your ext file system to use time based fsck you would need to run
Code:
man tune2fs

and look for the time based fsck options.

Author:  turpie [ Thu Jul 23, 2009 5:29 pm ]
Post subject: 

cliffsjunk wrote:
See man e2fsck.conf(5). Create a file /etc/e2fsck.conf, with the
contents:

[options]
allow_cancellation = true

Then you should be able to type ^C while it is doing a check, and
cancel the fsck.

Thanks Cliffsjunk,
I give that a go this weekend.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/