≡ Menu

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

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 38 comments… add one }
  • Yaw October 2, 2007, 2:38 pm

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

  • thewordsmith August 13, 2008, 5:24 pm

    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 March 25, 2009, 9:22 pm

    No …

    read http://linux.die.net/man/8/fsck 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 June 16, 2009, 2:47 pm

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

  • akrum September 22, 2009, 6:47 am

    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 October 2, 2010, 8:48 am

      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 March 1, 2012, 1:42 am

        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 September 30, 2012, 3:03 pm

          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 October 14, 2012, 3:10 am

            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 October 14, 2012, 8:07 pm

              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 January 30, 2013, 2:16 am

                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 January 31, 2011, 1:12 pm

      You are ridiculous, MORON!

    • aaron September 6, 2011, 12:55 pm

      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 September 24, 2009, 5:28 pm

    @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, 4:17 pm

    what the fsck… are you on drugs?

  • Lekensteyn November 27, 2010, 9:27 pm

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

    • jim November 7, 2011, 4:47 pm

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

  • Khalid Zaidi March 4, 2011, 10:59 am

    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 March 11, 2011, 8:50 pm

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

    • H5n1 March 12, 2011, 9:59 am

      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 June 29, 2011, 1:51 am

      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 February 21, 2012, 5:39 pm

    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 March 1, 2012, 1:43 am

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

  • thiyagi May 21, 2012, 5:43 pm

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

  • Edmond September 15, 2012, 4:44 am

    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 September 30, 2012, 2:30 pm

      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 October 1, 2012, 8:55 am

    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 October 14, 2012, 3:14 am

      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 October 1, 2012, 5:18 pm

    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 January 7, 2013, 1:11 pm

    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 January 30, 2013, 2:21 am

      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 February 19, 2014, 11:47 am

    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 March 16, 2014, 12:23 am

      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 February 19, 2014, 11:50 am

    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 March 16, 2014, 12:43 am

    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 March 16, 2014, 12:50 am

      Nice try. I know it was.

  • Michael February 24, 2016, 1:56 pm

    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 January 13, 2017, 3:11 pm

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

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , ,