[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Does ext3 file system use a '.journal' file?



On Thu, Jan 27, 2005 at 07:32:14PM -0500, Joseph D. Wagner wrote:
> > Does ext3 use a .journal file or is it hidden?
> 
> Both.  It's supposed to be hidden when mounted as EXT3, but you can see 
> it when mounted as EXT2.

Actually, that's not correct.  Normally the journal is hidden;
however, if you run tune2fs -j on a mounted filesystem, it can't
create the hidden inode safely, so it creates an immutable file called
.journal, and then sets the superblock to use the .journal file.

If you run e2fsck on the filesystem while it is not mounted, it will
automatically move the .journal inode to the reserved hidden journal
inode, and then remove the .journal file.  However, the root
filesystem is normally going to be mounted when e2fsck is run, so this
won't happen unless you run e2fsck from a rescue floppy.  

The real right thing would be to have the e2fsck of the root
filesystem happen out of the initial ramdisk, but no distribution I
know of does this at this point.

(Note that for Debian unstable, if you are using an initial ramdisk,
the simplest way to convert the root filesystem to use ext3 is to edit
/etc/fstab so that the root filesystem type is ext3, and then reboot.
The initial ramdisk script will then automatically run tune2fs -O
has_journal on the root filesystem, and since it is not mounted, the
journal will be created using the hidden inode.


> > If it DOES use a .journal file, can I rebuild it on the fly?
> 
> Yeah, just mount it as EXT2.  Then delete the .journal file, and use 
> tune2fs to rebuild a new one.  You should then be able to unmount and 
> remount as EXT3 just fine.

Nope, that won't work.  (Clearly, you didn't even bother to try this
before dispensing advice...)  First of all, if you try to delete the
.journal file, it is marked as an immutable file, so you won't be able
to do, even as root.  If you manually clear the .journal file, and
delete it, you will panic your system if it is mounted as ext3.  If it
is mounted as ext2, it will work, but the filesystem will be
corrupted, and e2fsck will complain and downgrade the filesystem to
ext2.  If you try to use tune2fs to rebuild the filesystem before you
run e2fsck, it will refuse, saying the filesystem already has a journal.

In general, there shouldn't be a reason to rebuild the journal.  Why
do you want to in the first place?  But if you want to change the size
of the journal, you can use "tune2fs -O ^has_journal" to clear the
journal safely and cleanly, and then "tune2fs -O has_journal" to
recreate the journal, possibly with a different size.  This has to be
done while the filesystem is unmounted, so this may not count as "on
the fly".  If by "on the fly", you mean while the filesystem is
mounted, the answer to that question is no.

						- Ted


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]