Converting an Ext File System to a Btrfs File System

You can perform the conversion of an Ext file system to Btrfs on file systems that aren't used as the root partition or the boot partition.

Caution:

Although the conversion tooling stores an image of the Ext file system metadata that you can use to roll back to soon after converting to Btrfs, ensure that you have a full backup of the file system in case the conversion fails or the rollback image is removed and you want to revert to using the Ext file system.

To convert an Ext file system other than the root file system to Btrfs:

  1. Unmount the file system.
    sudo umount mountpoint          
  2. Run the correct version of fsck (for example, fsck.ext4) on the underlying device to check and correct the integrity of file system.
    sudo fsck.extN -f device
  3. Convert the file system to a btrfs file system.
    sudo btrfs-convert device
  4. Edit the file /etc/fstab, and change the file system type of the file system to btrfs. For example:
    /dev/sdb               /myfs          btrfs    defaults  0 0
  5. Mount the converted file system on the old mount point.
    sudo mount device mountpoint           
  6. Verify the file system and review the Ext backup image.
    Check that the Btrfs file system is correctly initialized and that the data is still available on the file system. For example:
    sudo btrfs filesystem usage mountpoint
    ls -lah mountpoint

    Note that the file system includes a subvolume labeled ext2_saved:

    sudo btrfs subvolume list

    The subvolume contains an image of the Ext file system that can be used to roll the file system back to its original Ext file system type. You can roll the file system back by running:

    sudo umount mountpoint
    sudo btrfs-convert -r device

    The file system is rolled back to its original Ext file system type.

    The Ext file system image takes up disk space and might no longer be usable or required after you perform other disk or file system operations on the Btrfs file system. You can remove this backup by running:

    btrfs subvolume delete mountpoint/ext2_saved