How to convert file system from ext3 to ext4

Original author: wiki.kernel.org
  • Transfer
Now everyone has a new Ubuntu with ext4 support, and in my last post about its release there were several comments with questions about how to remake the file system into this very ext4. For this excellent reason, I decided to transfer the topic from wiki.kernel.org, where just about it is written. The translation is completely free, diluted with my own thoughts. By the way, about the new ext4 buns can be read in English is now in Russian here , but also in the new article yktoo 's here !

Mount ext3 as ext4 without conversion


First, starting with kernel 2.6.28, you can mount ext2, ext3, and ext4 file systems as ext4. This will make it possible to use new optimized gizmos of the new driver (for example, delayed allocation, multi-block allocation and large inodes if you formatted your ext3 with this option), while nothing will physically change on the disk, allowing you to go back to the ext3 driver , eg. This is done very simply - in your / etc / fstab you change ext3 to ext4 and that’s it. True.

Convert to ext4


It's quite another matter if you want to use new ext4 features, such as extents, which change the physical format of data storage, but also give a big gain in performance. If you are converting from ext2, you first need to enable logging (in other words, convert to ext3):

sudo tune2fs -j /dev/{нужный раздел}

Then, to enable new features on your ext3 file system, you need to do this:

sudo tune2fs -O extents,uninit_bg,dir_index /dev/{нужный раздел}

Attention! After this command, you will never be able to mount the file system as ext3.
After this, you must ( Mastyfsays that it’s not necessary, because on the first reboot everything will be checked by itself, but I would still be reinsured) check the file system with fsck to tidy up what tune2fs did not finish. We do it like this:

sudo e2fsck -pDf /dev/{нужный раздел}

After that, edit / etc / fstab and reboot.

Note : there are some new features that can be obtained only by reformatting the partition, for example, flex_bg and support for partitions larger than 16 terabytes.

One more note : it is not recommended to change the inode size using e2fsprogs version 1.41.0 or later, because it leads to corrupted data and sad people.

Last note: after you enable extents, new files will be created using them, but nothing will happen to the old ones and they will continue to lie on the disk in the old format. I read somewhere about the magic utility defrag2fs , which translates all the old files into a new format too, but, as I understand it, it is still very raw, it works poorly, is life threatening and it is better to wait.

How to boot if / boot is ext4 too


In general, converting / boot to ext4 is pointless. But if you really want to, then you must first do everything as described above. Then, you need to tweak /boot/grub/menu.lst a bit . We find this line: And add to the last at the end

title Ubuntu 9.04 <...>
root (hdX,Y)
kernel /boot/vmlinuz-2.6.28-... root=... ro quiet splash

rootfstype=ext4

Also popular now: