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?
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:
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:
To get a vague idea of progress watch:
1 2 3 4 5 6 7
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:
1 2 3 4 5 6