[Btrfs-devel] Yan's ext3->Btrfs conversion program pushed out

Chris Mason chris.mason at oracle.com
Fri Jan 4 08:57:24 PST 2008


Hello everyone,

The btrfs-progs-unstable tree now has Yan Zheng's conversion program.
It is not built by default (make convert to build it) and not installed
by default.  I'm sure there are some problems to work though, but this
is a very cool tool and I wanted to get it out there.

The overall conversion algorithm for this came from a bunch of people
including me, Zach Brown, Arjan van de Ven and Ted Tso.  Many thanks to
Yan for doing the implementation, which currently weighs in at 1279
lines.

The converter works in a few stages, and preserves the old ext3
metadata and data in a read only fashion.  It does not currently handle
xattrs or acls.

1) Get an ext3 FS, run fsck (must be done by the user)

2) Create a Btrfs filesystem in the free blocks of the ext3fs.

3) Use libe2fs to read the directory structure and files in the
ext3fs.  Files and directories are created in the Btrfs metadata that
correspond to the ext3 files.  The Btrfs file extents point to the ext3
file blocks (file data is not duplicated).

4) Create a subvolume in Btrfs named ext2_saved

5) Create a readonly sparse file in ext2_saved named image that
references all of the blocks used in the original ext3 filesystem.

After conversion, the 'default' subvolume has a read/write copy of all
the files in the original ext3 FS.  Because everything is copy on write,
none of the file blocks in the original ext3 FS will be changed.  

After conversion, you can:

mount -o subvol=. -t btrfs /dev/xxxx /mnt_point/
mount -o loop -t ext3 /mnt_point/ext2_saved/image /ext3

When you are happy with the conversion, you can delete ext2_saved/image
and the old ext3 data will no longer be preserved.  At some point,
we'll make a way to roll back the conversion.

-chris



More information about the Btrfs-devel mailing list