Convert boot filesystem from xfs to ext4

25,694

Solution 1

You can do this using fstransform, which is a tool to convert a filesystem type into another:

fstransform /dev/sda1 ext4

Currently it supports all main Linux filesystems i.e. ext2, ext3, ext4, jfs, ntfs, reiserfs, xfs.

Solution 2

There is an old post on serverfault.com, hope you will find your answer here:

changing filesystem format from xfs to ext4 without losing data

To quote the top answer:

i am unaware of any way to non-destructively convert a file system. this does not mean it is impossible, but i would put it at very low odds.

you can, for example, convert from ext2 to ext3 without wiping the disk, and from ext3 to ext4.

but to go from something like jfs to ext4 seems highly improbable, without first copying your /home files to another partition or external hard disk.

even then, you would want to create a new user on your system, with a home directory somewhere like /tmp/tempuser or copy your configurations for your user, usually the 'dot' files (files beginning with .) in your home directory to a new location off /home and updating /etc/passwd to use the new home directory, so you can log in as a normal user while you're performing this update.

then, back up your files, unmount /home and format it using /sbin/mkfs.ext4 or whatever tool you plan to use. mount the fresh partition at /home and copy your files back.

also, i would recommend something 'intelligent' like rsync to copy your files, to assure you preserve your permissions and all that jazz.

Share:
25,694

Related videos on Youtube

Thomas
Author by

Thomas

Updated on September 18, 2022

Comments

  • Thomas
    Thomas over 1 year

    I was wondering if it is possible to convert my boot system from xfs to ext4. If it is possible, how do I do so?

    Screenshot

    • dr_
      dr_ almost 7 years
      Why do you want to do that?
    • Thomas
      Thomas almost 7 years
      @dr01 It is part of a requirement of an assignment that I have to have it as ext4 but I just only discovered that it is wrong
  • Jeff Schaller
    Jeff Schaller almost 7 years
    Good find, but in the event that the serverfault page gets removed, we like answers here to be self-contained.
  • Nullpointer
    Nullpointer over 6 years
    If I execute this one then possibility to data loss ? If not then this is safe ?
  • dr_
    dr_ over 6 years
    There is always the possibility of data loss. Backup the data you cannot risk to lose. See the readme.md on GitHub.