Can I run fsck or e2fsck when Linux file system is mounted?

Q. Can I run fsck or e2fsck command when Linux file system is mounted? Do you advice to run fsck on a live file system? I am using Cent OS.

A. No. Do not run fsck on a live or mounted file system. fsck is used to check and optionally repair one or more Linux file systems. Running fsck on a mounted filesystem can usually result in disk / data corruption. So please do not do it. You have two choices
(a) Take down system to single user mode and unmout system

(b) Boot from the installation CD into rescue mode

(a) Take down system to single user mode and unmout system

Following are steps :
=> Use init (process control initialization ) command to change runlevel 1 (singe user mode)
=> Use umount command to unmount /home file system
=> Run fsck using fsck command

Let us say you would like to run fsck on /home (/dev/sda3):

# init 1
# umount /home
# umount /dev/sda

# fsck /homeOR
# fsck /dev/sda3OR
# e2fsck -y /dev/sda3

(b) Boot from the installation CD into rescue mode

If you are using Cent OS/Fedora Core/RHEL linux, boot from first CD and at boot prompt type linux rescue nomount:
boot: linux rescue nomount

Now make new node for disk and partition 3:
# mknod /dev/sda
# mknod /dev/sda3
# fsck /dev/sda3

# e2fsck -y /dev/sda3

Don’t forget to reboot the system:
# exit;exit
# reboot

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

🐧 38 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
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 glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep 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
38 comments… add one
  • Yaw Oct 2, 2007 @ 14:38

    l will like to know the big difference between fsck and e2fsck commands.

  • thewordsmith Aug 13, 2008 @ 17:24

    That advise above worked great. But I used to be able to rub “shutdown -rF 0” to force fsck to run on reboot. But as of Fedora 9 on my i686 32 bit system the -F option is missing. Is there any way to get that option back in the shutdown menue?

  • Victor Vitayaudom Mar 25, 2009 @ 21:22

    No …

    read and suggest flag -n if mounted

    For some filesystem-specific checkers, the -n option will cause the fs-specific fsck to avoid attempting to repair any problems, but simply report such problems to stdout. This is however not true for all filesystem-specific checkers. In particular, fsck.reiserfs(8) will not report any corruption if given this option. fsck.minix(8) does not support the -n option at all.

  • source Jun 16, 2009 @ 14:47

    This worked great. I was able to rescue a downed system.

  • akrum Sep 22, 2009 @ 6:47

    this is the difference between windows and linux! too many steps to do a very simple task like scandisk, and also i bear the risk of having my data corrupted because of a scanddisk under linux OMG!
    the best thing i’ll do is to take the HD off the machine, scand disk it under windows and back again into the linux machine!

    medieval but sounds much safer!

    • H5N1 Oct 2, 2010 @ 8:48

      1 – The real difference beween Linux and Windows is in troubleshooting: Windows = reboot | Linux = be root
      2 – Even in Windows you can have a Damaged System Disk after checking the disk for errors but Microsoft had never told you
      3 – Why THE F**K you think that if you want to correct sectors and FS errors you have to reboot in Windows and run chckdsk at boot-time? Obviously: you can’t do that on a mounted filesystem – just like in Linux!
      4 – Take the HD off the machine and mount it on a Windows System will notice that Windows cannot recognize the ext2/3/4 or any other Linux FileSystem. Strange, because almost any Linux System can recognize any Windows FS…
      5 – Make sure you have your brain set to “ON” before posting on any Web place…

      • Keilaron Mar 1, 2012 @ 1:42

        I love Linux, but I wish people would gets their facts straight about Windows…
        1. Windows = Be admin, use GUI. Linux = be root, find that file… if you’re lucky, someone else had that problem and it’s been documented.
        2. [citation needed]… at worst it continued to boot, but it did tell you and if you need a reminder, it’s in the log right in computer management.
        3. At least Windows can automatically unmount a disk (or partition) that is mounted but isn’t in use (and it will remount once done). In Linux you’d have to do this manually.
        4. Strange, because I can mount ext2/3 just fine in Windows… hmm…
        5. Make sure you have your bias set to “OFF” – and your politeness set to “ON” – before posting anywhere on the Internet, whether on the web or not.

        • H5N1 Sep 30, 2012 @ 15:03

          1 – You can have much infos in online documentation EVEN for Windows, but this is not the point. The point is that Microsoft, just like Apple (or Canonical in Ubuntu) think about a stupid user when building their systems. The system have to KNOW before you even know what to do and how. But when something goes wrong it’s difficult to find a solution since YOU DO NOT KNOW how the system is built.
          2 – If the damaged block contains a system file (ie the kernel or tha boot) you cannot boot the machine and got NO log.
          3 – Yes. I think that Linux can be run by everyone but used only by advanced users.
          4 – Keliaron, I’m not sure you’re telling the truth: Windows CANNOT recognize any Linux Filesystem. On Windows machine you can mount ONLY Fat16/Fat32/ExFAT/NTFS Filesystems.
          If you want your machine to work with other ones you have to provide some additional drivers.
          5 – I think that akrum was too irriverent.

          • Keilaron Oct 14, 2012 @ 3:10

            1 — Except knowing how the system is built only helps you if you can figure these things out yourself anyway; Otherwise, the end effect is the same. There’s a reason Linux is still not popular.
            2 — I was talking about when it does boot; when it doesn’t you get different symptoms that are in most cases visible onscreen (sometimes, though, you get no indication as to what the problem is). (By the way, if Linux can’t boot, you don’t get a log either – only what’s onscreen.)
            3 — Sadly, that’s the problem.
            4 — You are correct that *stock* Windows cannot. However, there are reliable drivers for ext2/3.
            5 — People may say stupid, uninformed, or mean things.. but in the end they’re just opinions. Don’t let it get to you.

            • H5N1 Oct 14, 2012 @ 20:07

              1 – I can agree a little bit, but I think that Linux is not popular for million reasons else.
              2 – Yep, sure.
              3 – Yep, again.
              4 – You can mount Ext partirions in Windows only if you install the relative drivers.
              5 – There’s a big difference from a statement and an opinion. If one just give his opinion, that’s right, but if he make a stupid statement I fell the moral right to reveal the stupidity of its statement.

              • Keilaron Jan 30, 2013 @ 2:16

                1 – I didn’t mean _literally_ one reason.
                4 – I don’t see how this is a problem. Windows and Mac (excluding the App Store *shudder*) have no package manager, thus lacking this, what would you do (aside implement one)? People already complain that they’re too fat after being installed (so you can’t include everything including the kitchen sink), nobody wants to stick the install disk in to install drivers (so you can’t do the above *without* wasting disk space), and everyone wants everything available now, now, now.

    • LordAzuzu Jan 31, 2011 @ 13:12

      You are ridiculous, MORON!

    • aaron Sep 6, 2011 @ 12:55

      That actually sounds insane and Linux fsck is much more consistent and accurate and advanced than windows scandisk. As well is the linux file system (choose one but default to ext3/4 to be normal) itself which is light years ahead of the trash called ntfs.

  • Dave Sep 24, 2009 @ 17:28

    @akrum This will actually not work at all. Windows scandisk will not recognize a Linux filesystem. What you are describing is actually the least safe option. Good luck with that.

  • Paulo May 24, 2010 @ 16:17

    what the fsck… are you on drugs?

  • Lekensteyn Nov 27, 2010 @ 21:27

    Unmout (2x)? I’t really should be unmount!

    • jim Nov 7, 2011 @ 16:47

      @ lekensteyn
      umount is the original command. some systems have an alias called unmount, but it calls umount

  • Khalid Zaidi Mar 4, 2011 @ 10:59

    when i start the computer Centos (2.6.18-53.1.19.e15) boot normally and hang up after
    Mounting local filesystems: [ OK ]
    Enabling local filesystems: [ OK ]
    and cursor jam and keyboard lights on/off contineously

    please resolve my problem

    Khalid Zaidi

    • jewy Mar 11, 2011 @ 20:50

      that bug only in centos? maybe any stick key on you keybord?

    • H5n1 Mar 12, 2011 @ 9:59

      Try to start you PC with a live distro: if it works it’s a system issue, if it doesn’t it’s an hardware issue.

    • Keilaron Jun 29, 2011 @ 1:51

      Those keyboard lights going on/off indicate what’s referred to as a “Kernel oops” – equivalent to a Windows bluescreen. Try to get a log somehow – maybe (maybe) another VT is enabled at that time, and you could e.g. hit alt-f8 to switch to it and get more verbose information. Or maybe use interactive mode. I don’t remember if CentOS has that.
      Like the others have suggested, try booting another system; A liveCD of CentOS if you can.. you might get more information. Maybe the drive is corrupt or your /etc/fstab is incorrect.

  • Paulio Feb 21, 2012 @ 17:39

    akrum does have a bit of a point.

    At least with Windows they’ve tried to be helpful. All you have to do is say that you’d like this disk checked before the next boot and restart the PC.
    It may not be as good a check as fsck (taking your word for it), but at least it’s quick.

    I don’t see any reason for not providing this functionality in Linux – Is there one?
    Why does it have to be awkward just because it’s Linux?

    • Keilaron Mar 1, 2012 @ 1:43

      Sad part is, Linux DOES provide this functionality.. there’s just no GUI for it! :(

  • thiyagi May 21, 2012 @ 17:43

    Thank for the info, will take notes of it too. Will be useful in future..

  • Edmond Sep 15, 2012 @ 4:44

    From my dmesg.txt file the following issuses were noticed:
    [ 2.374562] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
    [ 18.058424] udevd[253]: starting version 173
    [ 32.953222] EXT4-fs (sda1): re-mounted. Opts: errors=remount-ro,commit=0
    [ 117.531547] wlan0: authenticate with 08:76:ff:50:3b:bd (try 1)

    I’m new to Ubuntu and have been advised to fsck my system partitions in liveCD. Also to check If the bootable drive is SATA, then try putting it into ‘IDE compatibility mode’ in BIOS.
    Kindly let me have instructions on how to do this. I would be most grateful for your kind help.

    • Keilaron Sep 30, 2012 @ 14:30

      I don’t understand; What’s the problem? All of those seem fine to me. If you’re wondering about the “errors=remount-ro”, that just means that *if* there are errors, that filesystem will be remounted as read-only (instead of unmounted completely, I suppose?).

  • Edmond Oct 1, 2012 @ 8:55

    Thanks for your kind response. As my bootable drive is SATA, is it possible to try putting it into ‘IDE compatibility mode’ in BIOS? If possible kindly advise further.
    Thanks again and kind regards

    • Keilaron Oct 14, 2012 @ 3:14

      I just noticed that the log messages you posted did in fact say “remounting”, so perhaps there *is* a problem. At any rate I’m not sure IDE compatibility mode will help you, but I suppose it’s worth a shot.
      Yes, you *probably* can change it in your BIOS, but there’s no guarantee. You’ll have to look around.. it might be under the drive configuration, under chipset configuration, or buried somewhere else… or your BIOS might not have the option at all.
      If you have a manual for your motherboard/BIOS, I would look it up there first as it will probably make it easier to find.

  • Edmond Oct 1, 2012 @ 17:18

    Kindly advise if the following procedure to take down system to single user mode and unmout system works on Ubuntu 12.04:

    => Use init (process control initialization ) command to change runlevel 1 (singe user mode)
    => Use umount command to unmount /home file system
    => Run fsck using fsck command

    Kind regards

  • pd Jan 7, 2013 @ 13:11

    Hi may have expressed it in a horribly inflammatory way but I think he’s right. Scandisk or chkdsk is so much easier than checking file systems on Linux, it is incomparable.

    I swear in the olden days Linux (gawd knows which flavour) had a similar sort of option to scandisk or chkdsk. It worked very well. Why they ever got rid of that is only something pure Linux zealots can relate to.

    • Keilaron Jan 30, 2013 @ 2:21

      Maybe only that flavour had it, and that program got lost in time. I don’t suppose you remember the name of the program by any chance..?

  • Jorge_C Feb 19, 2014 @ 11:47

    There IS a linux app with a GUI for that, its called gParted. Its kind of like partition magic for windows except its free and does a whole lot more.

    • Keilaron Mar 16, 2014 @ 0:23

      Answers like this are why the problem doesn’t get fixed…

      First off, you’re ignoring the fact that part of the deal with this article is how to do it with your root FS, i.e., the one that is (almost) always mounted rw. You can’t just fsck it, with gparted or otherwise. In fact, gparted refuses to operated on any mounted partitions and the only option it gives you is to completely unmount it!
      Second, you still can’t schedule it easily — gparted will not do this for you (even though (at least I seem to recall) it is a flag stored in the FS metadata — assuming, of course, the system boot will pay attention to it, which is based on what’s in fstab).
      As for your other comment to use a live distro — you’re missing the point even further. Really, if you need to get, setup/burn/whatever, reboot into, and remain in that separate distro, that’s a lot of extra work. If you could simply right-click on a partition and select “Scan for errors on start” . . . that would be a step forward into .. what, 1984? While scandisk (and the need for it) was annoying, at least it existed and did correct (most) errors.

  • Jorge_C Feb 19, 2014 @ 11:50

    Just use gParted on linux. There is even a live distribution with gparted and some other disk utilities designed to recover filesystems on just about any system.

  • Jorge_C Mar 16, 2014 @ 0:43

    That comment was in reply to Keilaron’s post, not the main article so I excuse your poor post. And I accept your apology in advance.

    • Keilaron Mar 16, 2014 @ 0:50

      Nice try. I know it was.

  • Michael Feb 24, 2016 @ 13:56

    Boot server into: init=/bin/bash

    fsck -yC /dev/sd* (* is whichever is the partition you wish to run the fsck on)

    Reboot server and done.

  • Salah Eddine Jan 13, 2017 @ 15:11

    no you can’t run fsck in a mounted FileSystem : corruption Risque …

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