Repairing Linux ext2 or ext3 or ext4 File System [ fsck ]

Linux comes with the system utility fsck (“file system check”) for checking the consistency of a file system. This quick post explains how to use fsck to fix error.

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
# 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
# fsck.ext3 /dev/sda3
# 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,,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
Read man page of fsck for more information. Make sure you replace /dev/sda3 with your actual device name:
$ man fsck

Page last updated at 9:58 PM, April 10, 2012.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 22 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
22 comments… add one
  • Anonymous Oct 17, 2005 @ 2:20

    simple and effective 🙂 good pice of work

  • Anonymous Oct 17, 2005 @ 19:50

    can I try same commands on HP/UX?

  • LinuxTitli Oct 18, 2005 @ 0:32

    Commands are same but syntax changes.

    To repair HFS file system (/home)

    umount /home
    fsck –F hfs /dev/vg00/lvo1
    mount /home

    To repair JFS file system (/home)
    umount /home
    fsck –F vxfs /dev/vg00/lvo14
    mount /home

    Replace /dev/XXX/YYY with actual device file.

    • Michael Nov 8, 2011 @ 16:14

      To repair a file system in HPUX

      # fsck -F vxfs -y -o full /dev/vg##/lvol#
      # fsck -F vxfs -o full -y /mount_pt

      Note: The HFS file system has been obsoleted in HP-UX since version 10, except for the /stand file system which contains the kernel, and you’re not going to unmount the kernel and run a file system check. Instead, get to single user. Here is one way:

      # reboot
      # interact with IPL . yes
      ISL>hpux -is

      And as the kernel is loaded vg00 will be enabled and automatically checked for corruption.

      # init 2, same thing, automatically check run level 2
      # init 3, same thing, automatically check run level 3, multiprocessor mode. The system is up.

      NEVER! fsck /stand – The only hfs file system for over a decade is /stand, and you never fsck /stand!

  • Anonymous Oct 18, 2005 @ 23:25

    thanks for HP/UX JFS repair commands 🙂

  • General Zod Oct 27, 2006 @ 17:16

    Concise, very effecive and to the point. Just what was required.

  • General Zod Oct 27, 2006 @ 17:17

    excllent work

  • Jm Dec 4, 2006 @ 3:05

    What about to recover data that are deleted?
    Thanks anyway… 🙂

  • Lusidvicel Dec 18, 2006 @ 17:50

    Hello, i love! Let me in, please 🙂

  • Owain Mar 3, 2007 @ 22:03

    Thankyou – this page saved my life! (well, not literally). After checking loads of links that just told me what it said in the man page, here was a quick, easy and practical way to use the command.

  • jack Jun 10, 2007 @ 16:50

    How do you check the / partition – which cannot be unmounted since it still shows as “in use” after going to run level 1? Is there a way without rebooting?

  • Paolo Jul 14, 2008 @ 12:38

    Thanks, very good guide!

  • herson Dec 11, 2008 @ 4:32

    @Jack, I think that’s when you need to use a rescue disk. Most of the distros have this on their installation media.

  • Chris Dec 24, 2008 @ 9:10

    How do you find out what the actual device name is?

  • markthecarp Jan 28, 2009 @ 14:00

    This post is over two years old but still relevant today.

    I just used most of the steps described here to repair an ext3 partition on my Ubuntu desktop system. Only difference being I did not do “init 1”. I logged out to the gdm screen then did Ctl-Alt-F2 to get to a virtual console. I logged into the system and ran the commands with the exception of “init 1”.

    Thanks for a very helpful and concise article.

  • tuxsun1 Aug 3, 2009 @ 22:13

    Excellent article!!
    Is there a way to do this via SSH?
    What methods do you recommend for listing the mounted file systems?

  • bsuresh Nov 3, 2009 @ 7:07

    system not booting.because new root user created last time,not come guimode .so restart that p.c .not booting asked password or alt ctrl i gave that password .system restarted.what will i do?lasttime i worked that pc du /dev/hdc6 .but i don’t know about this cmd.may be reason is there

  • MRPOST Feb 12, 2011 @ 0:17

    Hi I am getting following mesage:
    Repair File system 1#
    I don’t know what to do now.
    Beofore this it is saying file system corrupted. Anybody please help help….

  • Jan Girke May 19, 2011 @ 13:12

    Don’t try that on Ubuntu 10.04.
    It will just shut down the system.

  • Sk. Shahin Rahman Dec 4, 2011 @ 7:28

    Thanks a lot for this helpful article

  • Isaiah Sep 25, 2012 @ 6:52

    Thanks for telling me to check for the filesystem of giving me the command. I should of read ahead but I was executing commands in order.

  • Miguel Angel Diaz Sep 30, 2015 @ 2:58

    checking filesystems fsck.ext3: Unable to resolve LABEL=/ lo solucione cambiando de posición el disco en el cable de datos de la PC.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum