How to upgrade to ext4 in place
Here’s how you upgrade to ext4. The process is pretty easy, but requires an fsck which means unmounting or rebooting if the file system is in use.
Make sure you are using at least e2fstools 1.41.3 and kernel 2.6.28 (or a vendor kernel with latest ext4 patches applied)! Also, its probably a good idea to have proper backups (really!). ext4 has just been declared stable, but what that really means is that the battle hardening has just begun. I’ve done several heavily used systems without fault so far though, so its probably good enough for your desktop.
WARNING: DON’T CONVERT YOUR /boot PARTITION. Right now, there is no stable version of grub with ext3 support. Even if there was, it really won’t gain you anything
.
Run tune2fs, e.g.:
tune2fs -I 256 -O sparse_super,filetype,resize_inode,dir_index,ext_attr,has_journal,\ extents,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize /dev/sd[x][n]
Those are the default options for an ext4 file system if you were to create it with mkfs.ext4 (e2fsprogs 1.41.3 – see /etc/mke2fs.conf). I’m getting pretty damn good performance with this! The ‘-I 256′ option sets 256 bit inodes, which most recent ext3 FSs use already. If this is the case, and you get a message telling you so, remove this option. Note that extents will make the FS backwards INCOMPATIBLE with ext3.
Next, edit /etc/fstab, e.g.:
/dev/vg/home /home ext4 defaults 0 0
Either unmount and mount or reboot your system. tune2fs marks the fs as dirty and performs a fsck and conversion.
NOTICE: distros with initrds may need to be regenerated or you won’t be able to mount your root file system. In Fedora (replace kernel version with your own):
cd /boot mv initrd-2.6.27.7-134.fc10.i686.img initrd-2.6.27.7-134.fc10.i686.img.old mkinitrd initrd-2.6.27.7-134.fc10.i686.img initrd-2.6.27.7-134.fc10.i686.
That’s all there is to it. Stay tuned for future ext4 developments like online defragmentation.
Also, ext{2,3,4} reserve 5% of space for root in case the drive fills up. On large modern drives, this can be excessive (e.g: 50GB on a 1TB disk). Consider running ‘tune2fs -m 1 /dev/sd[x][n]‘ to reduce this to 1%.
For more information and tweaking:
- Documentation/filesystems/ext4.txt from the latest kernel sources
- http://ext4.wiki.kernel.org/index.php/Main_Page
- man tune2fs
- http://e2fsprogs.sourceforge.net/
Related posts:
- One Small Step for QT, One Giant Leap for Free Software QT Softwar
- To users that miss xorg.conf and complain about it I get requ
- I dream of pervasive virtualization… I dream of
- Retrocomputing for Fun and Profit Buy Old C
- Phoronix Benchmarking.. Statistically Significant? and Other Performance Concerns Phoronix h










December 30th, 2008 at 2:45 pm
Excellent Instructions. I definitely recommend the backup. Had quite the scare today with my complicated Gentoo setup and still don’t have a successful conversion (cryptsetup home and pam mounted). I had to use debugfs to back off of the new ext4 features and use fsck to fix those “features” so that I could remount ext3.
I wouldn’t have lost much more than time and some pride had I lost my data but whatever I did different means these instructions aren’t foolproof. I either had segfault or CONFIG_LFS errors trying to mount the new ext4. I recompiled and installed the kernel with CONFIG_LFS with no improvement.
I may give this another try after I have a real backup.
-= Yet another Kevin running Gentoo =-
December 30th, 2008 at 7:20 pm
Be careful with the -I inode adjustment, I think it is getting some renovations right now so its best to do that as ext3. Probably better to chunk off the upgrades anyways, i.e do inodes, then extents, then the rest. FWIW your drive will appear corrupt a couple of times as fsck regenerates stuff, so it can look a little bit scary. I thought I hosed mine the first time around. But bottom line, if you don’t have backups and aren’t good with a LiveCD, stay away for now
.
December 30th, 2008 at 9:08 pm
I left the inodes alone since they were already at 256 as you had mentioned. I tried the conversion on my USB can and got the same error there. Between disabling huge_file and making darn sure I had LSF support I got the can to work and I’m doing an rsync to it now. Whenever that’s finished I’ll tackle home, root, then maybe getting the newest pam_mount to play nice with my encryption.
I’m anxious for this to finish. I’m hoping if nothing else this will increase my drive performance a bit. A lot of what I do seems to stall around the hdd and with a 7200 RPM drive I’ve seen some improvement but not as much as I had hoped. But hey, this is a year old laptop so what can I expect
I’ve timed a few of my common operations under ext3. I’d be glad to post some totally unscientific stats if you are interested.
December 30th, 2008 at 11:20 pm
Just some really initial figures with root and home fully ext4, and this is all I can probably compare since I rushed along and didn’t test any other apps…
From hitting Enter at the grub prompt till I could login dropped from 45 seconds to 40. From login to “Fully loaded*” XFCE dropped from 45 seconds to 25 seconds. Total boot till login time is now 65 seconds compared to 90 before.
*Fully loaded implies all my autostart stuff completed and the desktop is idle.
January 3rd, 2009 at 10:08 pm
[...] to upgrade from ext3 to ext4 without the need for reformatting such as the one on Kernelnewbies and Kev009.com. However the partition of which you want to upgrade the file system must be unmount which is some [...]
March 6th, 2009 at 4:20 am
Hi we build an ex4 gentoo liveCD. The CD is available under http://www.gentoolivecd.piffpaffpuff.net/
Have Fun
April 21st, 2009 at 1:59 pm
WARNING: DON’T CONVERT YOUR /boot PARTITION. Right now, there is no stable version of grub with ext3 support. Even if there was, it really won’t gain you anything
.
Err, you mean ext4.
July 3rd, 2009 at 7:48 am
I can’t wait ext4 developers from reinventing xfs !