Cool Solution - Convert ext3 to ext4

From Univention Wiki

Revision as of 13:47, 25 August 2014 by Frahm (talk | contribs)
Jump to: navigation, search
Produktlogo UCS Version 3.2

This article describes how to convert an existing ext3 file systems to an ext4 file system.

Non-Root filesystem

Non-root filesystems are rather unproblematic and can be converterd during ongoing business.

The first step is to umount the partition or device

umount /dev/partition

After the partition or device is unmounted you should check if there are any errors on it that should be fixed befor migrating to ext4

fsck.ext3 -pf /dev/partition

Now, the partition or device will be converted to ext4 using tune2fs

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

Afterwards, the filesystem must be checked again since it was changed

fsck.ext4 -yfD /dev/partition

After the check is done, the entry for your partition or device must be changed from ext3 to ext4.

Finally, mount the filesystem

mount /dev/partition

and the convertion is finished.

Boot partition

Regarding to the version of your bootloader, converting the /boot partition may not be working. But you can still mount your /boot partition as ext4 by editing it's entry in the /etc/fstab. However, booting from ext4 is possible with GRUB2 1.97 and should work on every 3.x UCS System.

The procdure for the /boot partition is the same as described in Non-root filesystem so, please refer to it.

Root partiton

To convert your root partition, you need to start your system via a Live-System (e.g. System Rescue CD). Apart from that, the procedure is the same as described in Non-Root filesystem. Note: If your root partition is a LVM, you need to select your LVM container to do the filesystem checks (fsck)

Migrate files to extents

The migration is nearly complete. All new files will use extents, but all already existing files will use the old bitmap mapping from ext3. To check if a file is already using extents, you can execute

lsattr /path/to/file

If you see an output similar to this

-----------------e- /path/to/file

your file already uses extents. If not, you can set extents for your files with the following command

find /home -xdev -type f -print0 | xargs -0 chattr +e

and for directorys with

find /home -xdev -type d -print0 | xargs -0 chattr +e

Afterwards the migration is fully completed and you can take advantage of ext4.

Personal tools