User:Nathanlkoch/Tutorials/Btrfs Drive Migration
Btrfs Drive Migration
Moving btrfs volumes to new disks is super easy. You don't have to mess around with resizing partitions because btrfs subvolumes expand as needed.
You would create your new partitions as normal. A fat32 boot for EFI and then your formatted btrfs luks partition like done in the tutorial created. User:Nathanlkoch/Tutorials/BTRFS Encryped Root On UEFI It's pretty straight forward. Mount your luks partitions after unlocking each luks disk. Once you have done the mount /mnt/btrfsmirror* stuff.
You will need to make several directories.
Then you mount your old drive as /mnt/btrfsmirror0 and the new drive as /mnt/btrfsmirror1.
Create the snapshots on the old drive.
btrfs subvolume snapshot /mnt/btrfsmirror0/activeroot /mnt/btrfsmirror0/activeroot.snapshot
btrfs subvolume snapshot /mnt/btrfsmirror0/home /mnt/btrfsmirror0/home.snapshot
Make the snapshots read only on the old drive.
btrfs subvolume snapshot -r /mnt/btrfsmirror0/activeroot.snapshot /mnt/btrfsmirror0/activeroot.readonly
btrfs subvolume snapshot -r /mnt/btrfsmirror0/home.snapshot /mnt/btrfsmirror0/home.readonly
Send the snapshots on the old drive to the new drive.
btrfs send /mnt/btrfsmirror0/activeroot.readonly | btrfs receive /mnt/btrfsmirror1/
btrfs send /mnt/btrfsmirror0/home.readonly | btrfs receive /mnt/btrfsmirror1/
Make the snapshots read/write on new drive.
btrfs subvolume snapshot /mnt/btrfsmirror1/activeroot.readonly /mnt/btrfsmirror1/activeroot
btrfs subvolume snapshot /mnt/btrfsmirror1/home.readonly /mnt/btrfsmirror1/home
Next you would just make your /mnt/newroot and mount your new btrfs root and home sub volumes , and boot directory like in the tutorial. Once mounted change your uuid in the /etc/default/grub file, maybe reinstall grub for safe measure, and change your fstab. For the vfat boot partition I just did a straight cp from /mnt/oldboot to /mnt/newboot after mounting the drive.
Then delete the snapshots you created after you have rebooted a few times, reinstalled grub, changed your /etc/default/grub files, and generated a new menu and fstab based on your updated UUID and partition numbers for fstab.
btrfs subvolume delete /mnt/btrfsmirror0/activeroot.readonly && btrfs subvolume delete /mnt/btrfsmirror1/activeroot.readonly && btrfs subvolume delete /mnt/btrfsmirror0/home.readonly &&
btrfs subvolume delete /mnt/btrfsmirror1/home.readonly