Migrate Existing ext3 Filesystem to ext4

The following collection of commands shows how to migrate your partition formatted with ext3 to an ext4 filesystem. The safest way is to do this when the partition is unmounted. However, if the partition to convert is where the root filesystem of your Linux distro is stored and you don't have access / time to boot from a Live CD, you can also do the conversion while simply remounting the root filesystem read-only.

I'm not going to go into detail why you would want to migrate to ext4. Check Wikipedia et.al. for good reasons.

# You need to become super user (root) of your Linux system:
sudo su # or simply su depending on your operating system

# make sure e2fsprogs are installed:
apt-get update && apt-get install e2fsprogs # or pacman -S e2fsprogs (on Arch Linux)

# find the correct ext3 partition you want to migrate to ext4:
fdisk -l

# store the choosen partition (/dev/sdX9) in $PARTITION:

# unmount the ext3 partition to convert:
# _OR_ if this partition to convert is your root fs, remount it ro:
mount -o remount,ro $PARTITION

# check & fix the current ext3 file system:
fsck.ext3 -pf $PARTITION
# ↑ If you get tired waiting for the check to return, send it to background using Ctrl-Z
#   enter  bg  to let it continue working in the background,
#   enter  killall -s SIGUSR1 fsck.ext3  and enter  fg  to get it back to foreground.
#   This will let you see a progress bar for the file system check.

# If the partition had been remounted read only you might want to reboot now
#   and remount the filesystem read only again when its up before you continue.

# Now prepare the filesystem for ext4:
tune2fs -O extents,uninit_bg,dir_index $PARTITION

# fix filesystem in order to let it function as ext4:
fsck.ext4 -pDf $PARTITION
# ↑ the options used are:
#   -p     Automatically  repair  ("preen")  the  file system.
#   -D     Optimize  directories  in filesystem
#   -f     Force checking even if the file system seems clean.
#   -C 0   Print a completion bar so that the progress can be monitored