|
|
Line 1: |
Line 1: |
| | | |
| == '''KVM''' == | | == '''KVM''' == |
− | | + | Show all Virtual Machines: |
− | | |
− | '''Creating copy of an existing VM''':<br/>
| |
− | Find the VM you want to save.
| |
| <pre> | | <pre> |
− | [root@localhost ~]# lvdisplay
| + | lvdisplay |
− | --- Logical volume ---
| |
− | LV Path /dev/vg1/kvm101_img
| |
− | LV Name kvm101_img
| |
− | VG Name vg1
| |
− | LV UUID ZCfjys-Ut9b-2iKZ-VFen-DG2i-79Hn-dfUnOf
| |
− | LV Write Access read/write
| |
− | LV Creation host, time ,
| |
− | LV Status available
| |
− | # open 1
| |
− | LV Size 30.00 GiB
| |
− | Current LE 960
| |
− | Segments 1
| |
− | Allocation inherit
| |
− | Read ahead sectors auto
| |
− | - currently set to 1024
| |
− | Block device 253:0
| |
| </pre> | | </pre> |
− | Shutdown it | + | Shutdown VM |
| <pre> | | <pre> |
| virsh shutdown kvm101 | | virsh shutdown kvm101 |
| </pre> | | </pre> |
− | Now create the backup
| |
− | <pre>
| |
− | dd if=/dev/vg1/kvm101_img | gzip | dd of=/home/kvm101_backup.gz bs=4096
| |
− | </pre>
| |
− | Make sure you replaced ''vg1'' with proper Volume Group.<br/>
| |
− | This archive can be used either for general backup or for cloning, migrating VMs.<br/>
| |
− | '''Restoring backup:'''<br/>
| |
− | Backup file can be sent to remote server:
| |
− | <pre>
| |
− | scp /home/kvm101_backup.gz root@remote.server.com:/home/
| |
− | </pre>
| |
− | See man scp if any issues.<br/>
| |
− | Create a logical volume the same size as the original one:
| |
− | <pre>
| |
− | lvcreate -n kvm101_img --size 30G /dev/vg1
| |
− | </pre>
| |
− | Restore backup to the new volume
| |
− | <pre>
| |
− | dd if=/home/kvm101_backup.gz | gzip -d | dd of=/dev/vg1/kvm101_img bs=4096
| |
− | </pre>
| |
− | If source VM became useless it can be removed
| |
− | <pre>
| |
− | lvremove /dev/vg1/kvm101_img
| |
− | </pre>
| |
− |
| |
| | | |
| == '''OpenVZ''' == | | == '''OpenVZ''' == |
Revision as of 14:53, 28 March 2013
KVM
Show all Virtual Machines:
lvdisplay
Shutdown VM
virsh shutdown kvm101
OpenVZ
Show all OpenVZ containers
vzlist -a