LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 05-13-2004, 03:13 PM   #1
Phaethar
Member
 
Registered: Oct 2003
Location: MN
Distribution: CentOS, Fedora
Posts: 182

Rep: Reputation: 30
Force filesystem check after improper shutdown?


Hey all,

I'm curious to know if there is a way to get Linux (Fedora for the most part) to check the filesystem by default after an improper shutdown. Normally, it will prompt the user to hit Y within 5 seconds of asking to do it. If Y isn't hit, it continues on booting normally. We have a lot of systems running unattended, and I'd like to find out if there is a way to force it to run that check if for whatever reason one of those systems goes down. Is there a way or an option I can enable to make this work?

Thanks.
 
Old 05-13-2004, 03:26 PM   #2
TheOther1
Member
 
Registered: Feb 2003
Location: Atlanta, GA
Distribution: RHAS 2.1, RHEL3, RHEL4, SLES 8.3, SLES 9, SLES9_64, SuSE 9.3 Pro, Ubuntu, Gentoo
Posts: 335

Rep: Reputation: 32
I'm guessing you could add this to /etc/rc.d/rc file

Code:
touch /forcefsck
and on next boot it will be forced. Adding ot to /etc/rc.d/rc will create /forcefsck every time system boots but I'm not sure if you will still need to hit Y.
 
Old 05-14-2004, 10:45 AM   #3
Phaethar
Member
 
Registered: Oct 2003
Location: MN
Distribution: CentOS, Fedora
Posts: 182

Original Poster
Rep: Reputation: 30
Thought I'd throw this out there as well... I think I've found the part of the rc.sysinit script that checks the FS on bootup and determines if the check needs to be run. Not being a programmer though, I don't know what I would need to change. I'm hoping someone can look at this and tell me how to get it to check by default.. it looks like the option is even in there. I just don't know how to get it. Here's the code I found:

Quote:
if [ -f /fsckoptions ]; then
fsckoptions=`cat /fsckoptions`
fi


if [ -f /forcefsck ] || strstr "$cmdline" forcefsck ; then
fsckoptions="-f $fsckoptions"
elif [ -f /.autofsck ]; then
if [ -x /usr/bin/rhgb-client ] && /usr/bin/rhgb-client --ping ; then
chvt 1
fi
echo $"Your system appears to have shut down uncleanly"
AUTOFSCK_TIMEOUT=5
[ -f /etc/sysconfig/autofsck ] && . /etc/sysconfig/autofsck
if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then
AUTOFSCK_OPT=-f
fi

if [ "$PROMPT" != "no" ]; then
if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then
if /sbin/getkey -c $AUTOFSCK_TIMEOUT -m $"Press N within %d seconds to not force file system integrity check..." n ; then
AUTOFSCK_OPT=
fi
else
if /sbin/getkey -c $AUTOFSCK_TIMEOUT -m $"Press Y within %d seconds to force file system integrity check..." y ; then

AUTOFSCK_OPT=-f
fi
fi
echo
else
# PROMPT not allowed
if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then
echo $"Forcing file system integrity check due to default setting"
else
echo $"Not forcing file system integrity check due to default setting"
fi
fi
fsckoptions="$AUTOFSCK_OPT $fsckoptions"
fi

if [ "$BOOTUP" = "color" ]; then
fsckoptions="-C $fsckoptions"
else
fsckoptions="-V $fsckoptions"
fi
Hopefully someone can make some sense of that...

I apologize.. the formatting wasn't saved when I posted it.
 
Old 07-21-2004, 09:54 AM   #4
gimbeault
LQ Newbie
 
Registered: Oct 2003
Posts: 1

Rep: Reputation: 0
Hi Phaethar,

this is what we did here in order to force the integrity scan.
We added the following line,(don't add the stars or arrows).

if [ -f /forcefsck ] || strstr "$cmdline" forcefsck ; then
fsckoptions="-f $fsckoptions"
elif [ -f /.autofsck ]; then
if [ -x /usr/bin/rhgb-client ] && /usr/bin/rhgb-client --ping ; then
chvt 1
fi
echo $"Your system appears to have shut down uncleanly"
AUTOFSCK_TIMEOUT=5
[ -f /etc/sysconfig/autofsck ] && . /etc/sysconfig/autofsck

AUTOFSCK_DEF_CHECK="yes" *****************<<<<<<

if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then
AUTOFSCK_OPT=-f
fi

In a nutshell this pretty much tells the script that the input was yes.
We did this on Trustix 2.1 Horizon and it works flawlessly.

We tried the following which also seemed to work fine,but I'm not a fan of leaving things blank and not knowing for sure why it worked

Instead of adding the new line, I removed the yes from in between the quote marks. Just leave it blank.

if [ "$AUTOFSCK_DEF_CHECK" = " " ]; then ******<<<<<<<<

Hope these help.
 
Old 07-21-2004, 10:17 AM   #5
Phaethar
Member
 
Registered: Oct 2003
Location: MN
Distribution: CentOS, Fedora
Posts: 182

Original Poster
Rep: Reputation: 30
Hi gimbeault,

Thanks a bunch for the tip, that's a nice and easy way to get it working, and it seems to be working great for Fedora as well now.

Thanks!
 
Old 07-22-2004, 10:03 AM   #6
TheOther1
Member
 
Registered: Feb 2003
Location: Atlanta, GA
Distribution: RHAS 2.1, RHEL3, RHEL4, SLES 8.3, SLES 9, SLES9_64, SuSE 9.3 Pro, Ubuntu, Gentoo
Posts: 335

Rep: Reputation: 32
Here's a cleaner way to do it w/o modifying the rc.sysinit script:

Code:
echo "AUTOFSCK_TIMEOUT=5" > /etc/sysconfig/autofsck
echo "AUTOFSCK_DEF_CHECK=yes" >> /etc/sysconfig/autofsck
This will do the same but you aren't messing with system files... Also it's easy to incorporate into a kickstart script or distribute the autofsck file to many servers through a simple script.

HTH!
 
Old 04-23-2011, 08:12 PM   #7
JWilliamCupp
Member
 
Registered: Jul 2005
Location: Indiana, U.S.A.
Distribution: Fedora
Posts: 32

Rep: Reputation: 15
Quote:
Originally Posted by TheOther1 View Post
I'm guessing you could add this to /etc/rc.d/rc file

Code:
touch /forcefsck
and on next boot it will be forced. Adding ot to /etc/rc.d/rc will create /forcefsck every time system boots but I'm not sure if you will still need to hit Y.
Thanks for this tip! It worked ...

Actually, I just entered
touch /forcefsck
from a console after I su'ed in as root, then rebooted.

It did a filesystem check on reboot, which I needed to do to clear an earlier problem.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
system stuck in loop after improper shutdown dr_zayus69 Linux - General 8 08-21-2005 02:30 PM
where to find improper shutdown logs linylion Linux - General 4 09-07-2004 11:59 PM
Unclean shutdown from power failure... filesystem check errors macisaac Linux - General 4 12-26-2003 07:50 PM
recovering from improper shutdown: ext3 kngharv Linux - Newbie 2 06-11-2003 09:29 PM
HDD problem after improper shutdown... Azazel Linux - Newbie 2 01-19-2003 10:03 PM


All times are GMT -5. The time now is 11:06 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration