Home | Download | Documentation | Programming | FAQ | About Me
Converting/Migrating from ext3/ext4 to btrfs and vice-versa:

make sure you have installed btrfs-progs packagae on your system. To test first create a 1GB file :
dd if=/dev/zero of=ext3.image bs=1MB count=1024
1024+0 records in
1024+0 records out
1024000000 bytes (1.0 GB) copied, 16.4318 s, 62.3 MB/s
We will test both ext3 and ext4 file systems. # dd if=/dev/zero of=ext4.image bs=1MB count=1024
1024+0 records in
1024+0 records out
1024000000 bytes (1.0 GB) copied, 11.5822 s, 88.4 MB/s
Format it as ext3 :
# mkfs.ext3 ext3.image
and ext4 :
# mkfs.ext4 ext4.image
Lets mount these file system and create some files :
First create mount point directories-
#mkdir /mnt/ext3
#mkdir /mnt/ext4
Okay. mount it -
mount ext3.image /mnt/ext3/ -o loop
mount ext4.image /mnt/ext4/ -o loop
for i in {1..1000};do echo "giis" > /mnt/ext3/$i.txt ;done
repeat the same for ext4.
for i in {1..1000};do echo "giis" > /mnt/ext4/$i.txt ;done
The setup is ready for conversion to btrfs.First make sure the existing ext3/ext4 file system are clean.
#fsck.ext4 ext4.image
e2fsck 1.41.9 (22-Aug-2009)
ext4.image: recovering journal
ext4.image: clean, 1011/62592 files, 9352/250000 blocks

#fsck.ext4 ext4.image
e2fsck 1.41.9 (22-Aug-2009)
ext4.image: recovering journal
ext4.image: clean, 1011/62592 files, 9352/250000 blocks

Running "mount" command should say something like -
/dev/loop0 on /mnt/ext4 type ext4 (rw)
/dev/loop1 on /mnt/ext3 type ext3 (rw)

Using btrfs-convert command to convert existing ext3/ext4 fs.
# btrfs-convert ext3.image
creating btrfs metadata.
creating ext2fs image file.
cleaning up system chunk.
conversion complete.

# btrfs-convert ext4.image
creating btrfs metadata.
creating ext2fs image file.
cleaning up system chunk.
conversion complete.

now umount and remount the file system -
umount /mnt/ext3
umount /mnt/ext4
mount -t btrfs ext4.image /mnt/ext4 -o loop
mount ext3.image /mnt/ext3/ -o loop -t btrfs
Now check the partition using mount command again -
dev/loop1 on /mnt/ext3 type btrfs (rw)
/dev/loop0 on /mnt/ext4 type btrfs (rw)
How migrate/rollback from btrfs to ext4/ext3:
#btrfs-convert -r ext4.image
rollback complete.
# btrfs-convert -r ext3.image
rollback complete.

Powered by
Open Source Programmers