# ext4 migration

## Tonglebeak

Is there a writeup/howto guide on migrating from ext3 to ext4? Just got 2.6.28 and can't wait to try it.

----------

## platojones

Not that I'm aware of...yet.  There are still some userland tools for ext4 (such as the defrag util) which haven't made it into the mainstream ext tools package yet.  But you can start by simply editing your fstab and changing any ext3 filesystems to ext4 (of course, after making sure that ext4 is built into your kernel).  I did that, and my system subjectively feels faster (meaning I haven't done any before/after benchmarks, but I can tell just by the way programs are loading up, it is faster).  You get many of the performance benefits of ext4 that way, simply by doing that one minor edit of fstab.

----------

## Tonglebeak

Alright thanks.

ext4 will need to be defragged???

----------

## platojones

 *Quote:*   

> ext4 will need to be defragged???

 

Here's the information on that:

http://en.wikipedia.org/wiki/Ext4#Online_defragmentation

----------

## i92guboj

 *Tonglebeak wrote:*   

> Is there a writeup/howto guide on migrating from ext3 to ext4?

 

Yes.

 *Tonglebeak wrote:*   

> ext4 will need to be defragged???

 

Hopefully, no. However a tool to defrag it manually is being done for what I know.

The full response to both questions is here: http://kernelnewbies.org/Ext4

----------

## platojones

 *i92guboj wrote:*   

>  *Tonglebeak wrote:*   Is there a writeup/howto guide on migrating from ext3 to ext4? 
> 
> Yes.
> 
>  *Tonglebeak wrote:*   ext4 will need to be defragged??? 
> ...

 

Thanks...I read that article too but just the highlights...*ducks*...then I couldn't find it again.  Trying it now on my non-root filesystem.  Very easy conversion it looks like.

----------

## i92guboj

Yep. I have converted everything except / (I am lazy, I'll do when I have the time to reboot from a livecd).

No problem so far here. The migration has been completely painless.

I only need to find if the ext3 drivers for Windows support ext4 before migrating my portable disks.   :Laughing: 

----------

## platojones

It would be prudent to refer to this post as well:

https://forums.gentoo.org/viewtopic-t-721928-highlight-.html

Bottom line is...do not convert your /boot partition to ext4 with extents...current stable grub can't read it.  Best to leave /boot as either ext3 or ext2.

----------

## i92guboj

 *platojones wrote:*   

> It would be prudent to refer to this post as well:
> 
> https://forums.gentoo.org/viewtopic-t-721928-highlight-.html
> 
> Bottom line is...do not convert your /boot partition to ext4 with extents...current stable grub can't read it.  Best to leave /boot as either ext3 or ext2.

 

There wouldn't be a benefit on doing that anyway.

----------

## platojones

Agreed, but some folks already have...and filed a bug on it against gentoo-sources-2.6.28 (250829, which is not a valid bug, IMO).

[EDIT]correction, the bug filed doesn't appear to be against gentoo-sources-2.6.28, but against grub, so that seems reasonable[/EDIT]

----------

## i92guboj

 *platojones wrote:*   

> Agreed, but some folks already have...and filed a bug on it against gentoo-sources-2.6.28 (250829, which is not a valid bug, IMO).
> 
> [EDIT]correction, the bug filed doesn't appear to be against gentoo-sources-2.6.28, but against grub, so that seems reasonable[/EDIT]

 

Hehe, yes. Some people is just too picky about these things. 

I also think that either way, it wouldn't be a valid bug. The feature set of grub doesn't have anything to do with the stability of a kernel or grub itself. If that was true, then grub would need to be able to boot like two hundreds file system types for it to be stabilized. No boot loaders that I know of can do that. It could be considered valid as a feature request, though. And only to upstream, and not in the Gentoo bugzilla (this is only my view of the matter).

----------

## Devport

Today a version of grub-0.97 with an ext4 patch landed in Sabyon overlay.

An ebuild for grub2 with ext4 support is available as well somewhere in the forum.Last edited by Devport on Sun Dec 28, 2008 3:00 am; edited 1 time in total

----------

## Gef

 *platojones wrote:*   

> But you can start by simply editing your fstab and changing any ext3 filesystems to ext4 (of course, after making sure that ext4 is built into your kernel).

 

This is what I did for / and /home. /home gets mounted with Ext4 with usual warnings (for not actually having extents feature) but / is still mounted as ext3.

Relevant parts of fstab :

 *Quote:*   

> /dev/sda5	     /boot	  ext2		noauto,noatime	   1 2
> 
> /dev/sda6	     /		  ext4		noatime		   0 1
> 
> /dev/sda7            /home        ext4          noatime            0 2

 

Relevant parts of Mtab :

 *Quote:*   

> rootfs / rootfs rw 0 0
> 
> /dev/root / ext3 rw,noatime,errors=continue,data=ordered 0 0
> 
> /proc /proc proc rw,nosuid,nodev,noexec 0 0
> ...

 

Dmesg

 *Quote:*   

> [    3.999708] EXT3-fs: mounted filesystem with ordered data mode.
> 
> [    4.037330] VFS: Mounted root (ext3 filesystem) readonly.
> 
> [    4.038302] kjournald starting.  Commit interval 5 seconds
> ...

 

I guess the kernel mounts root according to its "inner declared" format ? Or I forgot something.

Relevant part of Grub.conf : 

 *Quote:*   

> title=Gentoo Linux 2.6.28 Gentoo-r0 Low-Latency Tickless HRT IO=Deadline
> 
> root (hd0,4)
> 
> kernel /boot/kernel-genkernel-x86-2.6.28-gentoo-low-tickless-hrt root=/dev/sda6 udev vga=0x361 elevator=deadline

 

----------

## platojones

Could you post your fstab?

----------

## Gef

```
/dev/sda5        /boot     ext2      noauto,noatime      1 2

/dev/sda6        /        ext4      noatime         0 1

/dev/sda7            /home        ext4          noatime            0 2

/usr/portageFileExt4 /usr/portage ext4       loop,noatime,nodev 0 0

/dev/sda8        none     swap      sw         0 0

tmpfs                /tmp         tmpfs         defaults           0 0

/dev/sda9            /media/data  ntfs-3g       noatime,users,iocharset=utf8 0 0

/dev/sda2            /media/winxp ntfs          noatime,noauto,users,nls=utf8,ro,gid=10,uid=1000,umask=0   0 0

#/dev/sda2           /media/winxp ntfs-3g       noatime,users,iocharset=utf8 0 0

shm         /dev/shm   tmpfs      nodev,nosuid,noexec   0 0
```

Thanks in advance for any tip.

----------

## platojones

Did you reboot your box after you changed your fstab?

----------

## Gef

Sure. Several times.

I am wondering what sets the type of FS  "/" is mounted with. Kernel ? Udev ? Grub ?

----------

## platojones

 *Gef wrote:*   

> Sure. Several times.
> 
> I am wondering what sets the type of FS  "/" is mounted with. Kernel ? Udev ? Grub ?

 

Just checking...the FS type of root is set by fstab....this is unusual.  I'm going to have to think about this one.

----------

## platojones

Did you build ext4 support as a module or did you build it into the kernel?

EDIT:  Just to clarify where I am going...the kernel initially detects the FS type of root when it initially boots by reading the FS header on the partion..which is ext3...later it remounts the root FS after it reads fstab...if ext4 was built as a module, it may not be loading the ext4 kernel module until after it has remounted the root FS as read-write, so it stays as ext3...that's my theory right now.Last edited by platojones on Sun Dec 28, 2008 2:14 pm; edited 1 time in total

----------

## Gef

In-kernel :

zcat /proc/config.gz | grep EXT4

```
CONFIG_EXT4_FS=y

# CONFIG_EXT4DEV_COMPAT is not set

CONFIG_EXT4_FS_XATTR=y

# CONFIG_EXT4_FS_POSIX_ACL is not set

# CONFIG_EXT4_FS_SECURITY is not set
```

----------

## platojones

The only difference between what you have and I have...I have EXT4DEV_COMPAT enabled.  Try that.

----------

## Gef

Ok. I'll try* and report here, thanks. (even if it would be weird if that worked with EXT4DEV_COMPAT imho).

* as soon as i got rid of that java coding thing.

----------

## Gef

Same thing with newly compiled bzimage / modules.

Now doing a full cleanup of sources and rebuilding ...

----------

## platojones

 *Gef wrote:*   

> Same thing with newly compiled bzimage / modules.
> 
> Now doing a full cleanup of sources and rebuilding ...

 

Could you try adding "rootfstype=ext4" to your kernel boot line in grub.

----------

## Gef

 *Quote:*   

> [    3.990770] EXT4-fs warning (device sda6): ext4_fill_super: extents feature not enabled on this filesystem, use tune2fs.
> 
> [    4.030969] 
> 
> [    4.071754] EXT4-fs: barriers enabled
> ...

 

Brilliant ! Thanks for this tip.

I should have read Documentation/kernel-parameters.txt before !

----------

## rapsure

To convert your root partitions from ext3 to ext4. Make sure you are not using root to boot from as grub does not include support for ext4.

```

tune2fs -O extents,uninit_bg,dir_index /dev/root

```

mount your boot partition.

```

nano -w /boot/grub/grub.conf

```

add the kernel boot option

```
rootfstype=ext4
```

edit your /etc/fstab file and change the root to ext4 for the fstype.

reboot the computer and on the reboot root will get fscked and everything should be just fine.

Now I'm still looking for the defragger for ext4 so that I can move all the files to the extents mapping rather than block mapping. I've read the stuff at the ext4.wiki.kernel.org, but I haven't found the source code for the defrag utility.

ext3 becomes defragmented too, and so this is a nice new feature to go from a 6% non-contiguous to 0%. If the drive is really full then this will be even nicer as fragmentation can get quite severe.

----------

## tallica

Hello, I'm testing ext4 on mdraid partition (raid 0), here is a log

 *Quote:*   

> EXT4-fs: barriers enabled
> 
> kjournald2 starting.  Commit interval 5 seconds
> 
> EXT4 FS on md9, internal journal on md9:8
> ...

 

Should I ignore "barrier-based sync failed" ?

EDIT:

I've found that mdraid doesn't support barriers. So now I use barrier=0 option to get rid of barrier warnings...

 *Quote:*   

> EXT4-fs: barriers disabled
> 
> kjournald2 starting.  Commit interval 5 seconds
> 
> EXT4 FS on md9, internal journal on md9:8
> ...

 

----------

## ToeiRei

Does someone know the defrag tool for ext4? I haven't found a trace of something that looks like it would do so...

Rei

----------

## coolsnowmen

Does anyone know if/why you need CONFIG_LSF (Support for Large Single Files (LSF)) to use ext4?

I just formated an external harddrive (mke2fs -T ext4 -m 0) to play with it, and I couldn't even mount it. 

It should be empty but I get

 *Quote:*   

>  EXT4-fs: sdb1: Filesystem with huge files cannot be mounted read-write without CONFIG_LSF.

 

LSF says it is needed for files larger than 2TB, but the drive isn't even that big.

EDIT: kernel 2.6.28, latest e2fsprogs

----------

## paulbiz

i want to convert my 1.5tb dmcrypt raid from ext3 to ext4 but the thought of doing a full fsck frightens me... i wonder how many years it would take?  :Razz: 

has anyone got experience with a similar setup to estimate the time needed? IIRC e2fsck doesn't give any kind of progress... so you have no idea how far along it is. It just goes and goes until it is finished.   :Twisted Evil: 

EDIT: nevermind, i forgot about the -C option (or SIGUSR1 signal) to display the progress bar   :Shocked: Last edited by paulbiz on Fri Jan 02, 2009 6:32 pm; edited 1 time in total

----------

## Gef

You can monitor FSCK, printing a nasty progress bar :

```
# fsck -C0 /whatever/path/to/your/device
```

 *Quote:*   

> 
> 
> $ man e2fsk
> 
> <snip>
> ...

 

edit : something like "-pfvC0" would imho be a good combination  :Very Happy: 

----------

## paulbiz

 *Gef wrote:*   

> You can monitor FSCK, printing a nasty progress bar :
> 
> ```
> # fsck -C0 /whatever/path/to/your/device
> ```
> ...

 

Yep, I realized it after I posted   :Embarassed: 

I'm running fsck in read-only as a test... So far after 30 minutes it is 5% completed. So that means it will take "forever"  :Razz: 

----------

## candrews

Here are some bugs you may run into when trying to use ext4:

https://bugs.gentoo.org/show_bug.cgi?id=253162 "tune2fs -I 256" extremly slow

https://bugs.gentoo.org/show_bug.cgi?id=213541 sys-kernel/genkernel-3.4.10_pre7 EXT2-fs warning (device sda3): ext2_fill_super: mounting ext3 filesystem as ext2 (also affects ext4, see comments)

https://bugs.gentoo.org/show_bug.cgi?id=221245 rootfs is incorrectly mounted as ext2

I believe the last 2 are related, and will only apply to those who use genkernel and an initramfs.

----------

