Sysadmin/Migrate virtual machine: Difference between revisions

No edit summary
No edit summary
Line 6: Line 6:
  # virsh vol-create-as boot new.img 1G --format raw
  # virsh vol-create-as boot new.img 1G --format raw
  # virsh vol-upload --pool boot new.img existing.img
  # virsh vol-upload --pool boot new.img existing.img
=== Copying LVM volumes across machines ===
Create the new volume, format and mount it:
# virsh vol-create-as nvme-pool new-root 20G
# mkfs.ext4 -L new-root -O mmp,flex_bg,extent,uninit_bg,sparse_super /dev/nvme-pool/new-root
# tune2fs -c -1 -i 0 /dev/nvme-pool/new-root
# mkdir /new-root
# mount /dev/nvme-pool/new-root /new-root
Copy the contents of the remote filesystem (this can be done while the VM is online, but you might want to shutdown any running database to get a consistent snapshot):
# rsync -PHAXphax lightwave:/ /new-root/
Don't forget to unmount your new filesystem!
# umount /new-root
# rmdir /new-root
=== Importing a VM from existing disk files ===
# virt-install -v --accelerate --nographics --vcpus 2 --name lightwave --ram 1024 --os-type linux --os-variant=ubuntu20.04 --network bridge:br0 --disk vol=boot/lightwave-boot.img,bus=virtio --disk vol=nvme-pool/lightwave-root,bus=virtio --import


=== How to migrate a file-based guest to LVM (online method) ===
=== How to migrate a file-based guest to LVM (online method) ===