Next Previous Contents

5. Get, Set, Go...

5.1 Kernel Compilation (with ext3 patch)

	$ cp ext3-2.4-0.x.y.patch.gz /usr/src
        $ gunzip ext3-2.4-0.x.y.patch.gz
        $ patch -p0 < ext3-2.4-0.x.y.patch
        $ cd /usr/src/linux
        $ make mrproper
        $ make menuconfig

        Under the filesystems menu, select ext3.  
        Please also select "JBD debugging support", as it will produce useful 
        diagnostics if something goes wrong.

        The filesystem may be compiled into the kernel or built as a module.  
        Building it into the kernel can simplify the gathering of diagnostic 
        information if something fails.

        WARNING : If u are converting your existing ext2 root file system to 
                  ext3 than compile ext3 support in the kernel since u will 
                  need it on startup :-)

	Debian Users :
        ------------
                Once the above make menuconfig step is over, just type

                make-kpkg --revision=ext31.0 kernel-image

                to start compilation of the kernel. This will create a deb
                file in /usr/src with your customised kernel with ext3 support.

                Just type dpkg -i kernel-image* to install the new kernel :-)

                Edit your LILO (/etc/lilo.conf) or GRUB (/boot/grub/menu.lst)
                configuration file to reflect the new kernel. Update the MBR by
                giving the appropriate command for your boot loader.
                ( lilo -v for LILO )


        Redhat Users :
        ------------
                Redhat users are not so lucky as Debian users. You guys will 
                have to type the following commands to compile and install the
                kernel:

                $ make dep
                $ make clean
                $ make bzImage
                $ make install
                $ make modules
                $ make modules_install
                
                Edit your LILO (/etc/lilo.conf) or GRUB (/boot/grub/menu.lst)
                configuration file to reflect the new kernel. Update the MBR by
                giving the appropriate command for your boot loader.
                ( lilo -v for LILO )


        Voila !!! A major headache over .......... Hush.............

5.2 Converting ext2 filesystems

	An ext2 filesystem maybe converted to ext3 by creating a journal file
        on it.  To do this, run

                   tune2fs -j /dev/hdXX

        on the target filesystem.  The filesystem is now ext3!
        Note that the filesystem need not be unmounted for this operation.

5.3 Creating new ext3 filesystems

	Simply run

                   mke2fs -j /dev/hdXX

        to create a new ext3 filesystem on that device.

5.4 Filesystem check intervals

	A feature of e2fsck is that it will regularly force a check of a 
        filesystem even if the filesystem is marked clean. Typically, this
        happens on every twentieth mount or every 180 days, whichever comes
        first.

        This still happens with ext3, and is quite possibly not what you want
        to happen - one of the reasons you chose ext3 was to avoid the downtime
        which is caused by a long fsck.

        So it is a good idea to turn this feature off for ext3. 
        Use the command

                   tune2fs -i 0 /dev/hdxx

        To disable the checking.

5.5 Change /etc/fstab :

	This is very important. Just change ext2 to ext3 in /etc/fstab

        For ex. :

        /dev/hda3       /      ext2    defaults,errors=remount-ro 0       1

        change this to

        /dev/hda3       /      ext3    defaults,errors=remount-ro 0       1

5.6 ext3 on LVM : (Thanks to Andreas Dilger)

	Since an ext3 filesystem will not normally be checked at boot time, one
	option for long-running systems is to use the LVM snapshot feature to create
	a read-only snapshot of a filesystem and run a read-only e2fsck on the
	snapshot to ensure that your filesystem has not been corrupted by bad RAM,
	cables, disk drive, or kernel.

	You need to have your filesystem on an LVM Logical Volume, and you need the
	"LVM VFS Enhancement" patch applied for this to work properly (although it
	may work without the VFS enhancement patch on non-busy filesystems).

	For example, to run such a check on a Logical Volume (can be done at any
	time while the system is running, even from a cron script).  This assumes
	that you will not change more than 64MB of data in a single Logical Volume
	during the course of the e2fsck, and that you have this much space free in
	each volume group you want to test):

	    # simple but stupid LV listing (hardcoded LV names to check)
	    #for LV in /dev/vg00/lv1 /dev/vg00/lv2 /dev/vg01/lvA /dev/vg01/lvB; do
	    # this assumes that all LVs have ext2/ext3 filesystems on them
	    for LV in `lvscan | sed -n -e '/ACTIVE/s/[^\"]*\"//' -e 's/\".*//p'`; do
	        SNAP=lvtempsnap
        	SNAPDEV=`dirname $lv`/$SNAP
  	        lvcreate -L 80M -s -n $SNAP $LV
	        [ $? -ne 0 ] && echo "**** WARNING **** unable to check $LV" && continue
 	        e2fsck -fn $SNAPDEV
	        [ $? -ne 0 ] && echo "**** ERROR **** problem with filesystem on $LV"
	        lvremove -f $SNAPDEV
	        [ $? -ne 0 ] && echo "**** WARNING **** unable to remove $SNAP"
	    done


5.7 LILO options for the root filesystem

	If your root filesystem is ext3, an ext3-capable kernel will, by default,
	mount it using ext3. This may be overridden via the following LILO option:

	LILO: linux rootfstype=ext2

	You may provide mount options to the root filesystem via LILO using the
	rootflags option. For example:

	LILO: linux rootflags=data=journal

5.8 Auto recognizing ext3 filesystem

	The latest version of mount can automatically choose the ext3 filesystem
        type. For this you should have e2fsprogs >=1.23 installed on your system
	Just put 'auto' in /etc/fstab and mount will automatically recognise the
	ext3 file system. Here's how it works :

	1. If mount is not told the target fstype, and it detects ext3, it will 
           try ext3 and then ext2.

	2. If mount is told fstype auto then it will detect ext3 and will try 
           ext3 and then ext2.

	3. If fsck is told fstype auto then it will autodetect the type of the 
	   filesystem and run the appropriate checker (which is fsck.ext2 for
	   both ext2 and ext3).

	NOTE:
        ---- 
	a) If you are using a recent Red Hat distribution and if you have built your 
	   own util-linux from the official tarball you may have problems with mount 
	   failing to mount filesystems. This is because Red Hat have added the "-O" 
	   option to their version of mount. This option is used in their 
	   /etc/rc.d/rc.sysinit, and this causes the standard mount to fail with 
	   "unrecognised option -O".

           Fix: is to edit /etc/rc.d/rc.sysinit and remove any instances of 
	   "-O no_netdev".

	b) Using filesystem type auto for the root filesystem confuses /bin/df,
	   and causes it to not print out information for the root filesystem.�

	   Fix: always specify the root filesystem as ext3 in /etc/fstab.

5.9 External Journals

	As of version 0.9.5, ext3 supports the placement of the journal on a 
	separate device. It is intended that this be a magnetic disk, or an 
	NVRAM device. NVRAM devices may be simulated by using Andrew Tridgell's
	trivial RAM disk driver trd, which is in the ext3 CVS repository.

	You will need a very recent e2fsprogs.� Version 1.23-WIP-0727 or
	later.

	To install trd:

		mknod /dev/trd b 240 0
		insmod trd.o trd_size=50000
		(For a 50 megabyte device)

	To create an external journal:

		mke2fs -O journal_dev /dev/trd

	To create an ext3 filesystem on /dev/hda5 which uses the external journal
	device:

		mke2fs -J device=/dev/trd /dev/hda5
		mount /dev/hda5 /mnt/some/place -t ext3

	NOTE : 
	----

	a) You'll need to specify the filesystem type (-t ext3) because the 
	   automatic filesystem type detection in mount doesn't recognise ext3
	   with external journals.

	   Of course you may use a partition on a real disk as the external journal
	   device - just replace /dev/trd above with /dev/hdXX.

	b) Using a RAM disk driver to simulate an NVRAM device should ONLY be used for 
	   testing. Doing so will lose the benefits of journalling at recovery time 
	   (you will always get a full fsck of the filesystem), and in fact you will lose 
	   data and have an increased chance of filesystem corruption after a crash.


Next Previous Contents