What is /.journal?

Rick Stevens rstevens at vitalstream.com
Wed Dec 28 01:46:30 UTC 2005


On Tue, 2005-12-27 at 19:42 -0500, mylar wrote:
> On Tue, 2005-12-27 at 13:04, Rick Stevens wrote:
> > On Tue, 2005-12-27 at 20:04 +0300, A.Fadyushin at it-centre.ru wrote:
> > > The /.journal file is created when the _existing_ EXT2 filesystem is
> > > converted to EXT3 filesystem. That file contains the filesystem journal
> > > used by EXT3. The file is only created during the conversion EXT2->EXT3
> > > because it is impossible to create separate region on the existing EXT2
> > > filesystem for the journal - therefore, the journal is placed in the
> > > file /.journal (which is similar to regular files but is unremovable
> > > under EXT3). When the EXT3 filesystem is created anew, the journal is
> > > placed on disk separately from the space used for files' data, so there
> > > is no need to reserve that space via special file entry.
> > 
> > Perfect answer, Alexey.  That is correct.  If you convert an ext2 to
> > an ext3 filesystem, the system must put the journal somewhere, so it
> > creates a ".journal" file in the root of the filesystem and puts the
> > journal there.  A freshly created ext3 filesystem reserves space OUTSIDE
> > the namespace for the journal, hence it doesn't show up in a directory
> > listing.
> > 
> > It is important that you NOT delete the ".journal" file (permissions are
> > set so it's difficult to do anyway), because if you do, you will cease
> > to have an ext3 filesystem and you may even have issues mounting it
> > since the ext3 module wants a journal and won't be able to find it.
> > 
> 
> In short what  exactly does a journal do ? I know it has something to do
> with enabling the filessytem to recover.

The journal contains the actions necessary to make the disk image of
a filesystem current with what is in memory.  For example, if you write
a file, the journal will have the raw data and what actions to take.
Once the files have been adjusted on disk and the bitmap of the disk is
correct, the journal is purged.

Why does this work?  Manipulating the files on disk takes longer than
writing a stream of operations to a linear file.  If the system dies
before the on-disk images are updated, then the journal can be
"replayed" to bring it up to snuff.  Think of it like the
".filename.swp" file created by vi.  It records your keystrokes and such
in that file.  If your vi session dies, you can "vi -r filename", vi
replays the keystrokes in the .swp file and your edits are magically
restored.

> Also, sometimes when/if my system  with ext3 filesystems crashes when i
> restart the system asks if I want to run "fsck". Is it a good idea to
> run fsck or can I skip that step on an ext3 filesystem ?

The system should say "recovering journal".  If it does and the
filesystem comes up, you don't need to do an fsck.  If the filesystem
won't come up (fairly rare, but it does happen), then you have to do
an fsck.  The odds are that you'll lose some data in that case.

----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer     rstevens at vitalstream.com -
- VitalStream, Inc.                       http://www.vitalstream.com -
-                                                                    -
-         Microsoft Windows:  Proof that P.T. Barnum was right       -
----------------------------------------------------------------------




More information about the Redhat-install-list mailing list