Force fsck.ext4 on reboot, but really "forceful"
I know this is a really old thread, but I recently had to solve this problem so I wanted to post how to force the OS to fix problems found with fsck during bootup (for 12.04).
You do need to run the command sudo touch /forcefsck
. This will cause it to perform an fsck on the next boot. You can see the results of the fsck in /var/log/boot.log.
However, you are not guaranteed that fsck will fix anything it finds. To do this, you would need to edit the file /etc/default/rcS. There is a line at the end of that file:
FSCKFIX=no
This needs to be changed to the following:
FSCKFIX=yes
This will have the same effect as running the fsck with the -y option which will force all fixes that are possible to be implemented and it will not ask for user interaction.
This will allow you to run the fsck like the OP was asking to without having to resort to booting from a live disk which isn't always possible especially if you are on a remote system.
sudo touch /forcefsck
sudo reboot
You've got a typo- you're touching /forcefcsk. The "c" and the "s" are swapped. fsck is short for FileSystemChecK.
From the e2fsck man page :
"Note that in general it is not safe to run e2fsck on mounted filesystems. The only exception is if the -n option is specified, and -c, -l, or -L options are not specified. However, even if it is safe to do so, the results printed by e2fsck are not valid if the filesystem is mounted. If e2fsck asks whether or not you should check a filesystem which is mounted, the only correct answer is ''no''. Only experts who really know what they are doing should consider answering this question in any other way."
So if you check a mounted FS with fsck even using the -n option the result may be not valid at all. Don't check mounted filesystems. Use a Live-CD/Live-USB.
If you don't check the filesystem while it is mounted, I don't understand why you need to use touch /forcefsck
you can just unmount it and fix it. But if it is the case and after a fix your FS still have errors then you can consider using :
e2fsck -cy /dev/sda5
That will fix an hard drive related issue called bad blocks you may have (this will take a long time).
If you want to check a mounted filesystem, I don't know how to proceed but I think you should create another question.
You can not force a fsck on / that will repair because the partition is in use. Try running the check from a different partition or live cd.
You can have the revisions done automatically in the following way:
Tune2fs -c 5 -i 10 / dev / sda1
-c
is the maximum number of mounts before running fsck
and -i
is the maximum number of days before running fsck
.
In this case will be done every 5 mounts or every 10 days, whichever comes first.
I have two computers, one with Linux SuSE 13.2 and the other with Linux Mint 18.0 and in both it works perfectly.