fsck on EC2 Ubuntu machines

To force file system checks on remote Ubuntu machines, one of the common suggestions is to do a

sudo touch /forcefsck

before rebooting.  However, this is not guaranteed to work and it most often doesn’t work.  You need to enable the “y” option for fsck so that it goes ahead with doing any required fixes while booting.   To do that open /etc/default/rcS, find the last line that reads

#FSCKFIX=no

and change it to

FSCKFIX=yes

 

Once you make that change and do the touch /forcefsck command, fsck will do it’s best to fix thing when the remote system boots up the next time.