3

I have a btrfs partition on a drive which I would like to move to a new bigger drive. I would like to move the volume pretty much as is, retaining all the subvolumes and (snapper) snapshots.

What is the best way to do this, ideally with some way to check the integrity and fidelity of the copy?

Some things I have looked at:

btrfs send

I'm not sure how to rebuild the snapshot structure (I have to specify parents manually?), how sending multiple subvols at once works, how to best check the integrity (maybe just a diff of the directories including the .snapshot directories?), or whether I should be using the "clone" argument and what it does.

buttersink

Seems to be abandoned. Designed for backups. Not sure if it offers much more than btrfs send.

btrbk

Designed for backups, not sure it fits my use case.

dd

Probably too low-level, might have problems with block size, partition sizing, etc.

My impression at the moment is that "btrfs send" followed by a diff is the best bet but I don't know how to handle sending the numerous snapshots that are on each subvol.

1 Answer 1

2

Assuming that both the original btrfs partition and the new, bigger drive or partition are on the same system, the easiest/best way is probably to use btrfs replace.

See man btrfs-replace for details. Here's an extract, reformatted slightly to improve readability:

btrfs replace start [options] <srcdev>|<devid> <targetdev> <path>

Replace device of a btrfs filesystem.

On a live filesystem, duplicate the data to the target device which is currently stored on the source device.

If the source device is not available anymore, or if the -r option is set, the data is built only using the RAID redundancy mechanisms. After completion of the operation, the source device is removed from the filesystem.

If the <srcdev> is a numerical value, it is assumed to be the device id of the filesystem which is mounted at <path>, otherwise it is the path to the source device. If the source device is disconnected, from the system, you have to use the devid parameter format.

The <targetdev> needs to be same size or larger than the <srcdev>.

Note the filesystem has to be resized to fully take advantage of a larger target device; this can be achieved with

btrfs filesystem resize <devid>:max /path


BTW, even if you want to use all of the new drive for this btrfs volume, I recommend creating a partition table with one huge partition instead of just using the bare, un-partitioned drive. It's a convenient way of labelling and reserving the disk space, so that other programs don't assume it's unused free space and helpfully offer to partition and format it for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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