Advertisement
peetaur

how to manually clone a proxmox vm

Jul 24th, 2013
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. ======================
  2. step 1: new vm to fill
  3. ======================
  4.  
  5. in proxmox gui:
  6.  
  7. -create new vm with a 1GB disk
  8. -set things up however you like (choose bridge, network, ram, etc.)
  9. -this means it has a new MAC address
  10.  
  11. ======================
  12. step 2: copy the files
  13. ======================
  14.  
  15. in the proxmox host, command line:
  16.  
  17. # This should match the file from your old vm. The default proxmox is not "disk#.img".
  18. oldvmdisk=/mnt/mynas/images/100/disk1.img
  19. # This should match the new file created in step 1.
  20. newvmdisk=/mnt/mynas/images/101/disk1.img
  21.  
  22. qemu-img convert -O raw -p "$oldvmdisk" "$newvmdisk"
  23.  
  24. ======================
  25. step 3: update the vm OS configuration
  26. ======================
  27.  
  28. ---------------
  29. option A) without rebooting the VM
  30. ---------------
  31.  
  32. in the proxmox host, command line:
  33.  
  34. losetup /dev/loop5 "$newvmdisk"
  35. kpartx -a /dev/loop5
  36.  
  37. lsblk (figure out which dm-# device is right)
  38. dmdevice=dm-5
  39. mkdir /mnt/newvm
  40. mount /dev/"$dmdevice" /mnt/newvm
  41.  
  42. vim /mnt/newvm/etc/network/interfaces
  43. (change IP)
  44.  
  45. vim /etc/udev/rules.d/70-persistent-net.rules
  46. (delete or comment all lines)
  47.  
  48. umount /mnt/newvm ; kpartx -d /dev/loop5 ; losetup -d /dev/loop5
  49.  
  50. ---------------
  51. option B) with rebooting
  52. ---------------
  53.  
  54. in the proxmox host:
  55.  
  56. -Remove the vm from the bridge, so it has a NIC, but not a network. If you can't figure out how, just remove the whole network device.
  57.  
  58. -Start the vm
  59.  
  60. run the commands in the VM:
  61.  
  62. vim /mnt/newvm/etc/network/interfaces
  63. (change IP)
  64.  
  65. vim /etc/udev/rules.d/70-persistent-net.rules
  66. (delete or comment all lines)
  67.  
  68. shutdown -h now
  69. Stop vm (not restart)
  70.  
  71.  
  72. in the proxmox host:
  73.  
  74. -Add back the bridge or network device.
  75.  
  76. ======================
  77. step 4: start it and test it
  78. ======================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement