Linux Force fsck on the Next Reboot or Boot Sequence

by Vivek Gite · 17 comments

Q. I want to force fsck on the next reboot? How do I force fsck? Is there any configuration file that I need to alter for this purpose.

A. fsck is used to check and optionally repair one or more Linux file systems. You don't have to create or alter/modify any file. All you need to do is just create empty file /forcefsck.

Force fsck on boot using /forcefsck

By creating /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:
# reboot

Frce fsck on next boot using shutdown command

The -F option force fsck on reboot, login as root and type the following command to reboot and run fsck:
# shutdown -rF now

Featured Articles:

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 17 comments… read them below or add one }

1 Tom 02.26.07 at 8:53 pm

Good info. You don’t need to goto the root directory if you’re providing the full path, as you are. You can:
touch /forcefsck
from anywhere… You do need to cd / if you are using a relative path, such as
cd /
touch forcefsck
or
cd /
touch ./forcefsk
but not
cd ~
touch ../forcefsk
(changes to /root, and creates the file one directory level higher)

2 Ifan 09.24.07 at 5:21 pm

nice! didn’t know that at alL!!

3 sudar 02.19.08 at 6:39 am

Hi every one,
I’m able to reboot my target board using the command [reboot] from the bash prompt.
But i can able to by the command [reboot -f].
What should i need to do if i want to use the command [reboot]
Plz help me.
Thanks in Advance

4 dj 03.12.08 at 7:46 pm

shutdown -rF now <-will reboot and forcefsck now. More info: man shutdown

5 Martijn 07.10.08 at 10:05 am

@dj:

Your ’shutdown’ tip won’t work on many modern distributions, since they use Upstart instead of the old Sysvinit system.

Upstart has dropped many legacy commands that would be better done differently, in favor of a modern lean system.

‘touch /forcefsck’ is currently the most universal way.

6 Jason B 08.18.08 at 8:20 pm

On RHEL 4, ’shutdown -rF’ just writes /forcefsck anyway.

7 Nigel Horne 02.04.09 at 4:53 pm

There’s no need to use the touch command, “>/forcefsck” will do.

8 yanger 02.27.09 at 12:42 am

thanks! sudo touch /forcefsck is a good way :)

9 ankur 05.16.09 at 4:05 pm

What about trying to force fsck another partition ?

10 neurosys 06.26.09 at 9:40 am

then u could just umount it……

11 neurosys 06.26.09 at 9:41 am

umount /dev/hdb2; fsck -y -c -f /dev/hdb2;echo ‘w00t’

12 like how? 08.07.09 at 8:29 pm

me@mybox:/$ sudo umount /dev/hdb2
umount: /home: device is busy.
me@mybox:/$ echo ‘unwoot’

13 Axel Werner 09.01.09 at 1:16 pm

Will performing a “shutdown -rF now” or a “touch /forcefsck ” at a specific date and time once a week prevent the “automatic fsck” that is forced by the ext2/ext3 partition parameters ?? (can be set by tune2fs ) – i mean.. will it “reset” the timeouts/deadlines if doing a force fsck manualy once a week so there will be no “surprise” when trying to reboot my server if needed ?? any positive experience on that?

14 itpatil 12.11.09 at 10:11 am

Hey, thanks for the information. Appreciate it.

15 David Nuttall 02.08.10 at 6:21 pm

Running fsck, by whatever means, will cause the mount counter to be reset to 0. Well, so long as it completes successfully. If fsck dies for some reason (like trying to run on a mounted or read-only file system, oops) then the counter is not reset.

As for running on fsck on the partition mounted on /home, that should automagically mount, and will be checked at that time; just do (no quotes) “sudo touch /home/forcefsck” if mounted and if not mounted, you can run it directly, if you can log in, that is. Get to root and just run it one the device: “sudo fsck /dev/sda6″ or whatever device it is.

16 Light 02.24.10 at 7:43 am

Hi ,
I am going to check your tip hoping that ,this will work on My Ubuntu Karmic System with Ext4 File System.

17 Light 02.24.10 at 7:47 am

And Yes ,it Worked with Ext4 FS.Thanks for the Tip!

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous FAQ:

Next FAQ:

nixCraft FAQ PDF Collection Now Available To All