by ryanmjacobs · 5y ago · 0 comments
---
I've been looking for a way to copy virtual machine disks over the network with minimal downtime.
I.e. Copy the entire 50 GB disk over. Suspend the VM. Do a quick pass that picks up the changed blocks. Resume the VM.
Does anyone have a tool for that? It would be similar to how QEMU/KVM does it for VM migrations. (They only support doing it for RAM though.)
---
Also related, you can use the sysrq feature on Linux to remount the root file system as read-only. Then run `dd if=/dev/sda | ssh user@destination.com 'cat > sda.img'` to transfer the root partition consistently.
I've used this twice to migrate VPSs off of Cloud providers and onto my physical servers to convert to .qcow2 images. Worked perfectly :)
I'm not sure if you are required to reboot afterwards, but I always do. It would be nice to "un sysrq remount".
https://lwn.net/Articles/837053/
Also you can always do the fsfreeze yourself (which is what qemu agent can do, and is used by proxmox backup server).
I don't know of anything wrapping it, but if I was doing that I'd just put it on ZFS (handing zvols to qemu as disks) and then do incremental snapshots and send-recv them. (Bonus: trivial inline compression, and if you `zfs send --raw` even the transfer will be compressed)
The --raw/-w flag does send the compressed data.
It always feels brittle to me because of how manual the process is. Maybe it's time to create some decent scripts with safe logic and checks...