Bad code, bad humour and bad hair.

Moving My Butter (Btrfs)

Mar 21st, 2012

I recently had need to migrate a btrfs mount to a new physical device and I wasn’t immediately finding the answer with Google (shock horror!) so when I figured out the commands I thought I’d share them here.

So uhm, before doing anything dangerous to a drive you’ve taken a backup right?

Moving on…

I chose to use a process that let me do a live migration underneath the file system while there was still data being written to the file system… you know, for fun.

Adding in the new device is as simple as:

1

$ btrfs device add $new_device $existing_mount_point

Which is quick! Suddenly you have a whole bunch more data available.

Removing the old device takes a lot longer but the command is just as simple:

In this case /dev/sdb1 is the old drive and /dev/sdd is the new drive. The usage of the new drive will gradually grow until it catches up with the old one. In the capture above it’s about 19% (13.00GB / 688.29GB) complete.

Eventually when it completes /dev/sdb1 no longer shows in the device list: