I located a way to manually force a fsck at boot.

New to Debian (Or Linux in general)? Ask your questions here!

I located a way to manually force a fsck at boot.

Postby johngoodin » 2009-11-28 05:48

I located a way to manually force a fsck at boot.

HOWTO: Force fsck on boot using /forcefsck

By creating empty /forcefsck file you will force the Linux system (or rc scripts) to perform a full file system check.

Login as the root:
$ su -

Change directory to root (/) directory:
# cd /

Create a file called forcefsck:
# touch /forcefsck

Now reboot the system:
(Be sure you have no unsaved work before this last command)
# reboot

==================================

Q: Can I create a shell or script that I can launch from the
desktop and make fsck run the very next time I boot?

Better yet!

AKA Windows Scandisk after bad shutdown...

Is there a way to force linux to do a fsck if linux is not shutdown correctly?

I was thinking around the lines of making linux automatically create the empty
/forcefsck at boot and delete it during a proper shutdown.

If the system hung/locked up forcing a manual power off via the power button the empty /forcefsck would not be deleted and a fsck would follow at next boot. The same if the power was lost.
johngoodin
 
Posts: 15
Joined: 2007-06-03 18:57

Re: I located a way to manually force a fsck at boot.

Postby 987687 » 2009-12-10 14:16

Good idea. It would be fairly easy to do that. Just make an init script that checks for the fsckcheck file on boot. If it isn't there, create it, if it is there, run fsck, and then create it.
Another init script on shut down to delete the file. Then obviously if it doesn't shut down right the file will still be there for next boot.

One thing I'm not sure of is if fsck is run before init starts or not ... this wouldn't completely foil it though, instead it could just set the partition to fsck every boot, and set it back on shutdown.
Desktop - 3.2GHz core2 quad
Laptop - 2.4GHz core2 duo ancient macbook
Bring back the penguin!! http://tinyurl.com/d57jwv
User avatar
987687
 
Posts: 2121
Joined: 2007-06-11 10:58
Location: Vacation Land

Re: I located a way to manually force a fsck at boot.

Postby smallchange » 2009-12-10 14:52

Those M$ people are so smart. Why did it never occur to any Unix engineer to cause the file system to be checked at boot if it was not shutdown properly?
smallchange
 
Posts: 1740
Joined: 2009-05-04 15:56

Re: I located a way to manually force a fsck at boot.

Postby KeithHedger » 2009-12-15 20:59

I've just come over from ubuntu but as that is a debian system as well and so I presume works much the same way, I think you will find that if the system disk or home partition if you are using one is not cleanly unmounted it will do an fsck anyway, you may have just missed the check though as it can be quite speedy.
Pleas correct me if i'm wrong as i'm still exploring debian at the moment

P.S. just looked the files that do the startup check are at /etc/init.d/checkfs.sh and /etc/init.d/checkroot.sh
In /dev/null no one can hear the kernel panic
User avatar
KeithHedger
 
Posts: 17
Joined: 2009-12-07 19:55
Location: Devon, U.K.


Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 7 guests

fashionable