Translate

Image of Linux Kernel Development (3rd Edition)
Image of Android Wireless Application Development
Image of Beginning Google Maps API 3
Image of RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302) (Certification Press)

Some Ext4 Filesystems Cannot Be Converted to Btrfs

Not all ext4 filesystems can be converted to a btrfs filesystem using the btrfs-convert utility.

Btrfs has some limitations. The mkfs.btrfs utility will complain if you try to create a fileystem that is less than 256Mb. Btrfs-convert used fail when a file had more than 244 hard links associated with it but that limitation is long gone.

I hit another limitation recently when I tried to convert a 477Mb ext4 filesystem to btrfs. Btrfs-convert failed with a message of:

block size is too small

For some reason this Oracle document states that you cannot convert an ext4 /boot filesytem to btrfs because it is bootable. Maybe on an MBR-labeled disk but this should not apply to a GPT-labeled disk.

A look at the source code for the btrfs-convert utility revealed the real culpit:

ret = open_ext2fs(devname, &ext2_fs);
	if (ret) {
		fprintf(stderr, "unable to open the Ext2fsn");
		goto fail;
	}
	blocksize = ext2_fs->blocksize;
	total_bytes = (u64)ext2_fs->super->s_blocks_count * blocksize;
	if (blocksize < 4096) {
		fprintf(stderr, "block size is too smalln");
		goto fail;
	}


It seems the target filesystem blocksize has to be 4K or larger.

This (excellent) article on kernel.org explains how btrfs-convert does the conversion. Quite a complex operation!

By the way, the utility preserves an image of the original file system in a snapshot named ext2_saved. This snapshot allows you to roll back the conversion, even if you have made changes to the btrfs filesystem.

Note, on Fedora, btrfs-convert is part of the optional btrfs-progs package.

Comments are closed.