[wplug] fsck on mounted fs?

Poyner, Brandon bpoyner at ccac.edu
Wed May 18 09:07:47 EDT 2005


To elaborate on that further, you have to understand what fsck is doing
and how it does it.  Taking e2fsck as an example, you probably notice
that it seems to be doing 5 passes.  

fsck 1.27 (8-Mar-2002)
e2fsck 1.27 (8-Mar-2002)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sys/test: 11/51200 files (0.0% non-contiguous), 10590/204800 blocks

The first pass reads in each inode and does some basic sanity checking
of those inodes.  Every file and directory has an inode associated to
it.  The most important part here is that e2fsck caches what it learns
in pass 1 so that it doesn't have to read in all the inodes again for
passes 2-5.  If you start making changes to the file system in steps 2-5
after pass 1 has completed you can convince e2fsck that the file system
has problems.  

For further reading look at the section "The Ext2fs tools" at this URL

http://library.n0i.net/linux-unix/programming/design-ext2/


Brandon Poyner
Network Engineer III
CCAC - College Office
412-237-3086
 

-----Original Message-----
From: wplug-bounces+bpoyner=ccac.edu at wplug.org
[mailto:wplug-bounces+bpoyner=ccac.edu at wplug.org] On Behalf Of Bill
Moran
Sent: Tuesday, May 17, 2005 8:40 PM
To: Zachary Uram; General user list
Cc: wplug at wplug.org
Subject: Re: [wplug] fsck on mounted fs?

Zachary Uram <netrek at gmail.com> wrote:

> On 4/24/05, William N. Powell <billpwl1 at verizon.net> wrote:
> > 
> > I umounted /mnt/sysimage and ran fsck /dev/hda4 on it and it
indicated
> > no errors.
> 
> Can someone explain if/why it is bad idea to run fsck on a mounted
filesystem?
> I recall in rescue situation I had to mount the / fs and make it rw
> and then ran e2fsck to fix the problems, and it worked fine afer that.
> I've heard some say to NEVER fsck a mounted fs.

You can run fsck on mounted fs, as long as it's mounted read only.

Running fsck modifies the filesystem independently of the filesystem
code, thus it is possible to have fsck changing metadata at the same
time the filesystem code is changing it, and the result could be
a completely hosed filesystem.

Like many things in computers, there's a mathematical gamble involved.
You _might_ run it, and if the computer is relatively unused, it might
not cause any problems.  It's never a good idea, and it _can_ corrupt
your filesystem, but you also might get away with it.  How much are
you willing to gamble?

-- 
Bill Moran
Potential Technologies
http://www.potentialtech.com
_______________________________________________
wplug mailing list
wplug at wplug.org
http://www.wplug.org/mailman/listinfo/wplug




More information about the wplug mailing list