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

by Vivek Gite on December 5, 2006 · 16 comments

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

OR
# e2fsck -y /dev/sda3

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

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 16 comments… read them below or add one }

1 Yaw October 2, 2007

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

Reply

2 thewordsmith August 13, 2008

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?

Reply

3 Victor Vitayaudom March 25, 2009

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.

Reply

4 source June 16, 2009

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

Reply

5 akrum September 22, 2009

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!

Reply

6 H5N1 October 2, 2010

@akrum:
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…

Reply

7 LordAzuzu January 31, 2011

You are ridiculous, MORON!

Reply

8 aaron September 6, 2011

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.

Reply

9 Dave September 24, 2009

@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.

Reply

10 Paulo May 24, 2010

@Akrum
what the fsck… are you on drugs?

Reply

11 Lekensteyn November 27, 2010

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

Reply

12 jim November 7, 2011

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

Reply

13 Khalid Zaidi March 4, 2011

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

Reply

14 jewy March 11, 2011

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

Reply

15 H5n1 March 12, 2011

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.

Reply

16 Keilaron June 29, 2011

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.

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">




Previous post:

Next post: