Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I wish to convert my current /home partition to BTRFS (or other file systems) without losing data if possible, what steps should I take for this? is it safe?

share|improve this question

2 Answers 2

up vote 13 down vote accepted

If you install btrfs-tools with sudo apt-get install btrfs-tools, then the btrfs-convert command is made available to you.

First run an fsck:

sudo fsck.ext3 -f /dev/xxx

Then, convert!

sudo btrfs-convert /dev/xxx

To rollabck, run:

sudo btrfs-convert -r /dev/xxx

To clean up a bit of space, and make the conversion permanent, delete /ext2_saved/image on the partition.

Of course, while this is a relatively safe procedure as only 1 MB needs to be moved, and the original Ext2/3/4 FS is available as an image, it is up to you to decide whether to back up. As with any filesystem operations, there is an inherent risk of data loss.

Your data stays in place, as well as your Ext4 metadata. However, the first 1 MB is moved, and a series of BTRFS metadata is created within Ext4 free space.

Partial ref: https://btrfs.wiki.kernel.org/index.php/Conversion_from_Ext3

share|improve this answer
    
Let's say you have a 1TB disk with a 1TB Ext4 partition and it is used 80%. Can you convert it like this? You say that most data gets moved only, so my assumption is that you can convert nearly full partitions. Just want to be sure. –  bzero Nov 6 '13 at 8:59
    
@bzero Yes, so long as the disk has at least 1 MB free. –  hexafraction Nov 6 '13 at 14:27
2  
Maybe this would require another separate question, but I don't see in your answer any modification of fstab or grub. Will the next boot succeed if I only use btrfs-convert ? –  Xavier T. Jan 15 at 14:53
    
@XavierT. I personally do not know this. It looks from a new version of the source that fstab would need to be modified and a valid FS driver existent at boot. –  hexafraction Jan 15 at 17:58
    
@XavierT. You have to edit fstab if it mentions ext2/3/4 explicitly (just change it to auto or btrfs) or if it contains ext-specific mount options (needs to be evaluated on a case-by-case basis, open a question and post your fstab) or if it the line does not end in 0 0 (change it to 0 0). GRUB does not need a change, because it only deals with the root, not with the home. Doing btrfs-convert without fsck is like going to a car race without having a mechanic check your car beforehand - you may do it and succeed, but it is just stupid unless you have a very good reason. –  ignis Jun 21 at 12:51

You (and many others) use "sudo fsck.ext3 -f /dev/xxx" (with 3 "x"s) as an example. That's fine if you understand that xxx = a partition (which is typically 4 letters long, as in sdxn), not a volume (typically 3 letters long, as in sdx). In other words, use "sdb1" (or similar), not "sdb" (as I initially did, generating errors during fsck). I'm sure this is obvious to most, just wanted to clarify for the rest of us.

share|improve this answer
    
-1 Does not answer the question, does not add anything new compared to the older and previous answer, contains non-standard terminology (volume is Windows speak for partition, Linux calls them disks and partitions) –  ignis Jun 21 at 12:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.