use LVM volumes for your VirtualBox VMs This lesson shows using LVM snapshots to create backups and clones of running VirtualBox VMs without downtime
1 Preliminary Note
Installed VirtualBox on a headless server use phpvirtualbox as the VirtualBox GUI here. use the original VirtualBox GUI then only it will be perfect.
Running virtual machine named vm10 located on the LVM volume /dev/vg0/vm10.
logged in as root
Should run as root user
2 Create A Backup Of A Running VM With LVM Snapshots
create a backup of the running virtual machine vm10 Snapshots can be smaller than the original volume – 512MB
use dd to read the contents from the snapshot and pipe it to gzip to create a gzipped backup image in the directory
your backup of vm10 is now located in /backup/vm10.img.gz.
remove the LVM snapshot
3 Restore From A Backup/Clone From A Backup
cloning is essentially the same how to create a clone called vm11 from the backup we’ve just created
create an LVM volume of the same size as the original LVM volume
Restore the backup of vm10 to the local volume
gunzip -c /backup/vm10.img.gz | dd of=/dev/vg0/vm11 bs=64k
create a .vmdk file for
now it can be use it with VirtualBox
VBoxManage internalcommands createrawvmdk -filename vm11.vmdk -rawdisk /dev/vg0/vm11
chown vbox:vbox vm11.vmdk