4

I want to convert the 3TB 80% full ext4 block device into btrfs and I want to estimate the risks involved in the process.

If I accidentally lose power to the system during the conversion, will I lose the data?

In my two-year experience with btrfs, the file system proved only to be moderately safe during the power loss accidents - it destroyed some of my data, if the power was lost two or more times in the row.

1
  • 1
    Every time I try to submit an answer it throws me an error :/
    – ek9
    May 5, 2014 at 17:08

2 Answers 2

2

The data loose most possible due controller write operation failure to disk, while its possible that whole disk partition table would be corrupted.

As it was said, make a backup prior, but the conversion operation it self is designed so, that NO ORIGINAL DATA is touched. Btrfs makes snapshot of original FS version and uses free blocks to make further operations.

If you will create fresh ext4 FS on 100GB partition and run

#df -h
Filesystem                        Size  Used Avail Use% Mounted on
/dev/sda3                          99G   60M   94G   1% /ext4convert2btrfs

then unmount and run conversion:

#unmount /ext4convert2btrfs
#btrfs-convert /dev/sda3
creating btrfs metadata.
creating ext2fs image file.
cleaning up system chunk.
conversion complete.

then mount run df again, and you will see something like this:

Filesystem                        Size  Used Avail Use% Mounted on
/dev/sda3                         100G  1.8G   66G   3% /ext4convert2btrfs

The rest of space is used by primary FS snapshot. Only system administrator will decide when it is safe to remove snapshot and allow original data to be overwritten.

To recover free space and make the conversion permanent, do:

#cd /ext4convert2btrfs
#btrfs subvol delete ext2_saved
#btrfs balance start /ext4convert2btrfs
#df -h
Filesystem                        Size  Used Avail Use% Mounted on
/dev/sda3                         100G  544K   99G   1% /ext4convert2btrfs

That's it :)

3
  • The partition table can't be corrupted during the conversion because it isn't modified.
    – psusi
    Jan 24, 2015 at 23:21
  • I have experience that on power loss and immediate power back (main power pulsing), disk head flying writes trash to random sectors of disk, and especially close to zero track because of auto-parking during power loss. Feb 10, 2015 at 4:11
  • A flying write is a capital crime in the disk world; any disk doing so is defective. The emergency power off head retract is designed to prevent damage to the disk, not cause it.
    – psusi
    Feb 10, 2015 at 13:39
1

It is possible that your data might get corrupt in case of power loss during partition conversion. For this, it is always advised to make a backup before performing such operations.

Btrfs-convert however has a -r switch for reverting conversion, so you could resort to that to deconvert in case you have to cancel it. Also I found one user report that recovery is usually a lot faster in one of the answers here: https://askubuntu.com/questions/256652/ext4-to-btrfs-conversion-how-long-can-it-take-space-requirements

The conversion is relatively fast, so you shouldn't expect days to run it. I have recently converted ~20Gb partition on an SSD drive and it took a few seconds only. Assuming those 3TB of data is in HDD, it will take longer.

1
  • Can you also write, how many seconds it takes to read all the 20Gb of SSD drive? May 5, 2014 at 18:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .