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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
05-13-2004, 04:13 PM
|
#1
|
Member
Registered: Oct 2003
Location: MN
Distribution: CentOS, Fedora
Posts: 182
Rep:
|
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.
|
|
|
05-13-2004, 04:26 PM
|
#2
|
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:
|
I'm guessing you could add this to /etc/rc.d/rc file
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.
|
|
|
05-14-2004, 11:45 AM
|
#3
|
Member
Registered: Oct 2003
Location: MN
Distribution: CentOS, Fedora
Posts: 182
Original Poster
Rep:
|
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.
|
|
|
07-21-2004, 10:54 AM
|
#4
|
LQ Newbie
Registered: Oct 2003
Posts: 1
Rep:
|
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.
|
|
|
07-21-2004, 11:17 AM
|
#5
|
Member
Registered: Oct 2003
Location: MN
Distribution: CentOS, Fedora
Posts: 182
Original Poster
Rep:
|
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!
|
|
|
07-22-2004, 11:03 AM
|
#6
|
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:
|
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!
|
|
|
04-23-2011, 09:12 PM
|
#7
|
Member
Registered: Jul 2005
Location: Indiana, U.S.A.
Distribution: Fedora
Posts: 57
Rep:
|
Quote:
Originally Posted by TheOther1
I'm guessing you could add this to /etc/rc.d/rc file
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.
|
|
|
All times are GMT -5. The time now is 07:29 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|