20131207 notes on restoring kvm domains - plembo/onemoretech GitHub Wiki

title: Notes on restoring kvm domains link: https://onemoretech.wordpress.com/2013/12/07/notes-on-restoring-kvm-domains/ author: phil2nc description: post_id: 6738 created: 2013/12/07 11:46:42 created_gmt: 2013/12/07 16:46:42 comment_status: closed post_name: notes-on-restoring-kvm-domains status: publish post_type: post

Notes on restoring kvm domains

Before a recent rebuild, I had several kvm guests set up on one host. The rebuild, of course, wiped out their configurations. Here are my notes on how I restored them. There are two basic components to every kvm guest on Linux. The virtual disk image file, and the guest (a/k/a domain) definition file. The default locations for these on Red Hat inspired hosts are as follows: Images, /var/lib/libvirt/images Definitions, /etc/libvirt/qemu Disk images can have any extension, but most often it is .img (file types also vary, I usually use qcow2). Definitions usually have the same name as the corresponding .img file, but with an .xml extension. So guest test01 would have a test01.img disk file and test01.xml definition file. On my hosts I add a second virtual file system for my guest images that resides on a bigger disk than the default image directory. It is important to back both these locations up because without both you won't be able to restore your guests. When restoring guests to the same machine or moving to another machine you need to either set them up exactly the same as the original host or modify the guest xml definition file to reflect the differences. The most important parameter to get right is the full path of the disk image found in the devices branch of the configuration. Most other things can be modified later in a gui like the Virtual Machine Manager once the guest has been restored. The steps: 1. Copy all virtual disk images to your images directory (default is /var/lib/libvirt/images). 2. Copy all saved xml definition files to the configuration directory (default is /etc/libvirt/qemu). 3. Edit the definition files to conform virtual disk image paths to their actual location (if different from the originals). 4. Import the definition files.

[root@mine ~]# virsh define /etc/libvirt/qemu/test01.xml
Domain test01 defined from /etc/libvirt/qemu/test01.xml

5. Modify guest configuration as needed, like those for network devices (my previous host had included a bridge device for routing guests to my local network, in the new setup they'll all live on the default virtual network). 6. Start the guest to test.

Copyright 2004-2019 Phil Lembo