Some time ago ext4 was released and available for Linux kernel. ext4 provides some additional benefits and perforce over ext3 file system. You can easily convert ext3 to ext4 file system. The next release of Fedora, 11, will default to the ext4 file system unless serious regressions are seen. In this quick tutorial you will learn about converting ext3 to ext4 file system.
ext4 Filesystem Features
The ext4 filesystem has more features and generally better performance than ext3, which is showing its age in the Linux filesystem world. Features include:
Delayed allocation & mballoc allocator for better on-disk allocation
- Sub-second timestamps
- Space preallocation
- Journal checksumming
- Large (>2T) file support
- Large (>16T) filesystem support
- Defragmentation support
You need ext4 patch applied into kernel and compile kernel with ext4 support. Once done type the following command to convert an existing ext3 filesystem to use ext4, type:
# tune2fs -O extents,uninit_bg,dir_index /dev/dev-name
For example convert /dev/sdb1 to ext4, enter:
# cd /; umount /dev/sdb1
# tune2fs -O extents,uninit_bg,dir_index /dev/sdb1
Next run fsck, enter:
# fsck -pf /dev/sdb1
How do I mount ext4 partition?
mount -t ext4 /dev/sdb1 /path
mount -t ext4 /dev/sdb1 /share
mount -t ext4 /dev/disk/by-uuid/YOUR-PARTITION-UUID /share
Use blkid to get UUID.
How do I boot from ext4 (/boot)?
If you have converted /boot file system (or / used for /boot), update /boot/grub.conf (/boot/grub/menu.lst). Open file and find out current kernel config file and append the following:
rootfstype=ext4
Here is sample config (note I’ve custom kernel names):
title Ubuntu 8.10, kernel 2.6.28.1-vmware-guest-server root (hd0,1) kernel /boot/vmlinuz-2.6.28.1-vmware-guest-server root=UUID=8c2da865-13f4-47a2-9c92-2f31738469e8 ro quiet splash rootfstype=ext4 initrd /boot/initrd.img-2.6.28.1-vmware-guest-server quiet
Save and close the file. And run update-grub:
$ sudo update-grub
Next, update your /etc/fstab file so that it can be mounted as ext4 file system:
UUID=41c22818-fbad-4da6-8196-c816df0b7aa8 /share ext4 defaults,errors=remount-ro,relatime 0 1
Finally, reboot the system:
$ sudo reboot
Further readings:
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 21 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Hi,
I want to convert my xfs file system to ext4 on CentOS 7 box. Please help me in this.
Regards,
Thanks,
was very helpful, old article, but well written.
probably best descriptive article on this topic.
My 1.3 TB filesystem is converted successfully.
This is an incomplete tutorial if you read.
Need to specify -D with the ext4 fsck for a start. See for info.
Another reference advised to run fsck.ext4 with -D after tune2fs:
fsck.ext4 -yfD /dev/sdc1
Linas also advised enabling extents on all files / directories which will save the trouble of copying things around in order to achieve the full ext4 benefit. I used this after mounting the partition:
find . -xdev -type f -print0 |
while read -d $” FILE; do chattr +e “${FILE}”; done
find . -xdev -type d -print0 |
while read -d $” DIR; do chattr +e “${DIR}”; done
Cheers!
“How do I boot from ext4 (/boot)?”
The info in this section is incorrect please do not use. See the grub wiki for correct details on how to modify a grub2 boot files.
Any more good web sites on ext 4 and or the new grub 2 ?
I don’t understand why people are using ext3 or ext4 for /boot. Isn’t ext2 good enough ? Why the journaling would be useful for this partition ?
Hi,
In Redhat and Fedora there is /etc/grub.conf or /boot/grub/grub.conf not /boot/grub.conf (in How do I boot from ext4 (/boot)?)
sir
i want to know depth of linux file system can you provide me detail matter..
i am very much thankfull to you.
your faithfully
brijesh kumar
allahabad (india)
If you “convert” from ext3 to ext4 only new created files are “true” ext4, the existing files are still ext3-like, so existing files are as slow as usual, and deleting those files is as slow as usual too.
Use fresh formatted ext4 or copy the files around (not move inside one partition!) will help.
Oh yeah, when you reboot it seems to break a couple of desktop applets such as Quicklaunch (at least in my VM). And I did not notice an increase in boot times at all like so many have reported. Maybe it only applies to a fresh format ext4 w/ Ubuntu disc.
In case of Debian lenny: the fs-type must be “ext4dev” in fstab, since debian does not yet consider ext4 stable enough to call it “ext4”, that will probably make it in sid.
First time i heard about ext4 file system. thanks for the information
Ext4 users are reporting few problems :
http://ubuntuforums.org/showpost.php?p=6796365&postcount=251
and thread:
http://ubuntuforums.org/showthread.php?t=965879
—
Then ,we need e2fsprogs 1.41 or higher for ext4.kernel 2.6.28 for stable(eh?) ext4 unlike ext4dev.then converting a Linux root system from ext3 to ext4.Isn’t it risky with the current status of kernel support?
Great knowledge base that i ever found…….. 🙂
@ Peter / Alec
BobCFC is correct about defragmentation. This new feature is called online fragmentation. Right now it is *NOT* available in v2.6.28, but will be probably available in the next release. Quoting from ext4 wiki:
Thanks I am using Ext4 with Jaunty Alpha 3 as my main system for / and /home partitions (using the Alternated CD) and it is so fast I don’t even notice that I enabled encryption for the whole home directory. Now I can convert my data partitions too!
BTW I think the defrag feature refers to on-the-fly defragging while in use.
@ Peter:
I agree. File system fragmentation???
I’ve always enjoyed my linux clients and servers because I never had to schedule routine defragmentations like I have to do with Windows’ FAT and NTFS partitions…
I will have to look into this some and experement.
Thanks for the great post Vivek!
From your post it says a benefit of ext4 is Defragmentation support. What is happening here … I thought the benefit of linux file systems was that the files did not fragment ………. Are we about to see a flood of Windows style disk defragmenters?
@Daniel,
The post has been updated.
Appreciate your comment.
I just did this in Intrepid the other day, but took a different approach. You may want to advise your readers that Grub won’t boot to an ext4 partition. Since I have a separate /boot, I just converted my / to ext4 with no problems.
This is really simple actually, just requires a couple reboots:
sudo nano /etc/fstab
-change the fs type from ext3 to ext4dev for you root partition, the default options for ext4dev have extents enabled, so you cannot switch back to ext3
sudo touch /forcefsck
-this runs a fsck on reboot
sudo reboot
-let it run through the fsck, and once the system is up reboot again, it will need one more reboot and fsck to correct the journal
mount
-should list your partition as using ext4dev as the fs type