GagA// 0n D nEt

It is currently Sat Feb 24, 2018 11:56 pm

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Linux: Converting ext3 filesystem to ext4
PostPosted: Sat Jan 24, 2009 11:02 pm 

Joined: Wed Jul 18, 2007 1:14 am
Posts: 181
With the release of ext4 file system you can now look forward to switch the filesystem on your linux machines from ext3 to ext4.

Features of ext4 filesystem

The following are a few of the features for ext4 filesystem:
    *  Large file system - Able to support volumes with size up to 1 exabyte and files with size up to 16 terabyte.
    *  Extents - replaces block mapping scheme used in ext2/3 filesystems. This improves large files performance and reduces fragmentation.
    *  Backward compatibility - with ext3 which results in easy conversion from ext3 to ext4.
    *  Journal checksumming - Uses checksums in the journal to improve the reliability.
    *  Online defragmentation - ext4 has a tool which can defragment individual files or entire file systems.

For the complete list of features included, please click here.

Demerits as per my opinion would be following:

* The biggest would be the partial forward compatibility. An ext4 filesystem can be mounted as ext3, however if the ext4 filesystem is using the extents feature, then the ability to mount the filesystem as ext3 is lost.

Steps to convert ext3 filesystem to ext4

NOTE: The following steps will convert the existing ext3 filesystem to ext4 using the extents which will result is the disability to mount the partition as ext3 again. The ext4 filesystem has just been launched (as of when I am writing this article) and there might be a few bugs, which are yet to be discovered, hence it is not advised to switch a production system to ext4. You can try it on a non-production environment though. However, please try to avoid converting the /boot partition to ext4. Let it run on ext3 partition for sometime.

You will have to apply the patch for ext4 to your kernel and compile the kernel for ext4 support. I will be considering the partition to be converted as /dev/sda1 from here onwards, please change the partition as per your requirements. Once that is done use the following commands:
[[email protected] ~]# cd /
[[email protected] ~]# umount /dev/sda1
[[email protected] ~]# tune2fs -O extents,uninit_bg,dir_index /dev/sda1

Run an fsck to check the filesystem sanity
[[email protected] ~]# fsck -pf /dev/sda1

Mount the ext4 partition

[[email protected] ~]# mount -t ext4 /dev/sda1 /root

In case you convert the /boot partition or / partition (which includes /boot as a folder and not mounted separately), you will have to modify the grub in order to boot the from an ext4 filesystem.

Open the /boot/grub/grub.conf file (/etc/grub/menu.lst for debian/ubuntu), locate the kernel line for the current kernel/OS which is booting and add the following at the end of the kernel line:

So the grub should look something like below:
title           Ubuntu 8.10, kernel 2.6.28-1-generic
uuid            c64023e8-98e9-4a3c-9cd0-3535439254b6
kernel          /vmlinuz-2.6.28-1-generic root=UUID=8091942a-5d81-421e-a3e9-ba25f36ff93d ro quiet splash rootfstype=ext4
initrd          /initrd.img-2.6.28-1-generic

Save and quit the file. Update the grub to have the changes take effect (for debian/ubuntu):
[[email protected] ~]# update-grub

Update the /etc/fstab file to have it mount the partition as ext4. You can add the line similar to the one given below:
/dev/sda1    /root    ext4     defaults,errors=remount-ro,relatime 0       1

Once done, verify it's working with a reboot:
[[email protected] ~]# reboot

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group