What's new
SNBForums

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

fsck boot script

  • Thread starter Thread starter krabs
  • Start date Start date
K

krabs

Guest
Use this script for checking your partions with fsck at boot after a desired number of reboots

Check maximum mount with tune2fs -l /dev/partion
Change to your desired value with tune2fs -c value /dev/partion

Create a pre-mount script.
https://github.com/RMerl/asuswrt-merlin/wiki/User-scripts

Code:
#!/bin/sh
MOUNTS=$(tune2fs -l /dev/PARTION | awk '/^Mount count/ {print $3}')
if [ $MOUNTS -gt YOUR VALUE ]
then
fsck.ext2/3 -vfcy /dev/PARTION
fi
 
Thanks, that's interesting stuff.

I wonder how reliable the tunefs -l statistics are, though. Mine look a little dubious:
Code:
Filesystem created:       Tue Mar  1 06:58:23 2011
Last mount time:          Fri Dec 31 16:00:16 2010
Last write time:          Fri Dec 31 16:00:16 2010
Mount count:              14
Maximum mount count:      30
Last checked:             Thu Apr 11 14:41:37 2013
Check interval:           15552000 (6 months)
Next check after:         Tue Oct  8 14:41:37 2013
The "last checked" date is probably correct, the one and only time I manually fscked this drive. This is a vanilla Seagate USB hard disk. Is this normal tunefs output?
 
Hi,

My tune2fs -l output looks like:
Code:
tune2fs 1.41.14 (22-Dec-2010)
Filesystem created:       Sat Oct 30 19:29:11 2010
Last mount time:          Sat Jan  1 01:00:11 2011
Last write time:          Tue Jun  4 08:14:23 2013
Mount count:              35
Maximum mount count:      39
Last checked:             Sat Feb 16 12:17:34 2013
Check interval:           15552000 (6 months)
Next check after:         Thu Aug 15 13:17:34 2013

My dates are fully correct:
Filesystem created: Sat Oct 30 19:29:11 2010
==> Yep, the disk is running since nearly 3 years attached to the router (actually the 3rd router in 3 years :p ).
Last mount time: Sat Jan 1 01:00:11 2011
==> Remember that the router starts with date Jan. 1st 2011 and 01:00:00 time! Only after the WAN comes up the router get's the current time. You can see this also in the system.log.
Last write time: Tue Jun 4 08:14:23 2013
==> Again correct: Just rebooted to let it run the filesystem check.
Mount count: 35
Maximum mount count: 39
Last checked: Sat Feb 16 12:17:34 2013

==> That's the reason I am doing a filesystem now! :)

With kind regards
Joe :cool:
 
Last edited:
krabs, pre-mount script always gets one parameter — a current partition, no need to hardcode it into script. As long as it called for every recognized partitions, you can make universal script to check all of them:

Code:
# cat /jffs/scripts/pre-mount
#!/bin/sh

logger -t $(basename $0) "started [$@]"

grep -q $1 /proc/mounts || e2fsck -p $1 2>&1 | logger -t e2fsck
 
krabs, pre-mount script always gets one parameter — a current partition, no need to hardcode it into script. As long as it called for every recognized partitions, you can make universal script to check all of them:

Code:
# cat /jffs/scripts/pre-mount
#!/bin/sh

logger -t $(basename $0) "started [$@]"

grep -q $1 /proc/mounts || e2fsck -p $1 2>&1 | logger -t e2fsck

It's an old posting. But just make sure I have get this right.
Just put ryzhov_al script in pre-mount script in jffs and when reboot or run manual check all usb drives,
I have two which is mounted with label.
 
Last edited:

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top