table of contents
BTRFS-CONVERT(8) | Btrfs Manual | BTRFS-CONVERT(8) |
NAME¶
btrfs-convert - convert from ext2/3/4 filesystem to btrfs in-place
SYNOPSIS¶
btrfs-convert [options] <device>
DESCRIPTION¶
btrfs-convert is used to convert existing ext2/3/4 filesystem image to a btrfs filesystem in-place. The original filesystem image is accessible subvolume named ext2_saved as file image.
Warning
If you are going to perform rollback to ext2/3/4, you should not execute btrfs balance command on the converted filesystem. This will change the extent layout and make btrfs-convert unable to rollback.
The conversion utilizes free space of the original filesystem. The exact estimate of the required space cannot be foretold. The final btrfs metadata might occupy several gigabytes on a hundreds-gigabyte filesystem.
If you decide not to rollback anymore, it is recommended to perform a few more steps to transform the btrfs filesystem to a more compact layout. The conversion inherits the original data block fragmentation and the metadata blocks are bound to the original free space layout.
Due to different constraints, it’s possible to convert only filesystem that have supported data block size (ie. the same that would be valid for mkfs.btrfs). This is typically the system page size (4KiB on x86_64 machines).
Note
The source filesystem should be clean, you are encouraged to run the fsck tool if you’re not sure.
REMOVE THE ORIGINAL FILESYSTEM METADATA
By removing the ext2_saved subvolume, all metadata of the original filesystem will be removed:
# btrfs subvolume delete /mnt/ext2_saved
At this point it’s not possible to do rollback. The filesystem is usable but may be impacted by the fragmentation inherited from the original filesystem.
MAKE FILE DATA MORE CONTIGUOUS
An optional but recommended step is to run defragmentation on the entire filesystem. This will attempt to make file extents more contiguous.
# btrfs filesystem defrag -v -r -f -t 32M /mnt/btrfs
Verbose recursive defragmentation (-v, -r), flush data per-file (-f) with target extent size 32MiB (-t).
ATTEMPT TO MAKE BTRFS METADATA MORE COMPACT
Optional but recommended step.
The metadata block groups after conversion may be smaller than the default size (256MiB or 1GiB). Running a balance will attempt to merge the block groups. This depends on the free space layout (and fragmentation) and may fail due to lack of enough work space. This is a soft error leaving the filesystem usable but the block group layout may remain unchanged.
Note that balance operation takes a lot of time, please see also btrfs-balance(8).
# btrfs balance start -m /mnt/btrfs
OPTIONS¶
-d|--no-datasum
-i|--no-xattr
-n|--no-inline
-N|--nodesize <SIZE>
-r|--rollback
-l|--label <LABEL>
-L|--copy-label
-O|--features <feature1>[,<feature2>...]
To see all available features that btrfs-convert supports run:
btrfs-convert -O list-all
-p|--progress
--no-progress
EXIT STATUS¶
btrfs-convert will return 0 if no error happened. If any problems happened, 1 will be returned.
SEE ALSO¶
08/03/2017 | Btrfs v4.9.1 |