The syntax is as follows to check and optionally repair one or more Linux file systems:

fsck Fs-Name-Here
fsck /dev/xyz
fsck /home
fsck.ext3 /dev/hdc1
fsck.ext2 /dev/flash/device/name

Fs-Name-Here can be one of the following

  1. A device name (e.g. /dev/hda1, /dev/sda2, /dev/md0, /dev/vg1/volume_1)
  2. A mount point (e.g. /var, /home)
  3. An ext2 label (e.g. LABEL=home )
  4. UUID specifier (e.g. UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd)

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 (ext2), enter:

# fsck /dev/sda3

OR

# 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 multiuser mode, enter:

# init 3