Check the runlevel we are:

runlevel

First, a file system must be unmounted. You cannot repair it while it is running. Take system down to runlevel one (make sure you run all command as root user):

init 1

Next, unmount file system, for example if it is /home (/dev/sda3) file system then type command:

umount /home

OR

umount /dev/sda3

Finally, run fsck on the partition, enter:

fsck /dev/sda3

However be sure to specify the file system type using -t option. Recently, one of our sys admin run the command on ext3 file system w/o specifying file system. Result was more corruption as fsck by default assumes ext2 file system:

fsck -t ext3 /dev/sda3

OR

fsck.ext3 /dev/sda3

OR

fsck.ext4 /dev/sda5

If you do not know your file system type then typing mount command will display file system type.

mount

Sample outputs:

/dev/root on / type ext4 (rw,relatime,barrier=0,journal_checksum,data=ordered) /tmp on /tmp type tmpfs (0) none on /dev/pts type devpts (gid=4,mode=620) /sys on /sys type sysfs (0) /proc/bus/usb on /proc/bus/usb type usbfs (0) /dev/vg1/volume_1 on /volume1 type ext4 (usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0,synoacl) /volume1/@optware on /opt type bind (bind) none on /proc/fs/nfsd type nfsd (0) fsck will check the file system and ask which problems should be fixed or corrected. If you don’t want to type ‘y’ every time then you can pass -y option to fsck:

fsck -y /dev/sda3

Please not if any files are recovered then they are placed in /home/lost+found directory by fsck command.

Don’t execute, just show what would be done:

fsck -N /dev/sda3

Once fsck finished, remount the file system:

mount /home

Go to the previous runlevel:

init N