Cool Solution - Convert ext3 to ext4

From Univention Wiki

Jump to: navigation, search
Produktlogo UCS Version 3.2

Note: Cool Solutions are articles documenting additional functionality based on Univention products. Not all of the shown steps in the article are covered by Univention Support. For questions about your support coverage contact your contact person at Univention before you want to implement one of the shown steps.

Also regard the legal notes at Terms of Service.

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

Please note: ext4 is the default file system for new installations since UCS 3.x. If your UCS 3.x system still uses ext3 you probably installed UCS 2.x and upgraded to UCS 3.x

Non-Root filesystem

Non-root filesystems can be converterd while your UCS system is running.

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 that should be fixed before 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 in your /etc/fstab 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 UCS 3.x system.

The procedure for the /boot partition is the same as described in Non-root filesystem.

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). Depending on your Live-System this might be something like /dev/mapper/vg_ucs or /dev/dm-0.

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