• Comments
  • SUMMARY Simple method to convert EXT4 to XFS without data restore

    Posted on

    Hello esteemed forum members.

    For a specific project, I was asked to test if conversion of EXT4 to XFS could work without data restores on RHEL 7.9.

    I did it by using EPEL tool fstransform (available in RHEL repositories).

    Maybe this information helps someone else in the future.

    Step 1
    Install tool from EPEL repository:
    
    $ sudo yum -y install fstransform
    
    
    Step 2
    Check current setup for file system /myfs:
    
    $ uname -a && sudo lsblk -f | awk '$NF=="/myfs" {print $NF,"is file system type",$2}' 
    Linux myhost.domain.dom 3.10.0-1160.25.1.el7.x86_64 #1 SMP Tue Apr 13 18:55:45 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux
    /myfs is file system type ext4
    
    $ sudo mount | grep myfs
    /dev/mapper/myvg-mylv on /myfs type ext4 (rw,noatime,data=ordered)
    
    
    Step 3
    Unmount file system /myfs and run the conversion:
    
    $ sudo umount /myfs
    
    $ sudo fstransform /dev/mapper/myvg-mylv xfs
    
    
    Step 4
    Change file system type in /etc/fstab and remount /myfs:
    
    $ sudo sed -i -e "s#/myfs.*ext4#/myfs xfs#" /etc/fstab
    
    $ sudo mount /myfs
    
    $ uname -a && sudo lsblk -f | awk '$NF=="/myfs" {print $NF,"is file system type",$2}'
    Linux myhost.domain.dom 3.10.0-1160.25.1.el7.x86_64 #1 SMP Tue Apr 13 18:55:45 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux
    /myfs is file system type xfs
    

    Yes, certainly there are some caveats and backups are important in case something goes wrong.

    Regards,

    Dusan Baljevic (amateur radio VK2COT)

    by

    points

    Responses

    Red Hat
    © 2025 Red Hat, Inc.