[CentOS] KVM Questions

Sat May 9 05:41:19 UTC 2015
James Hogarth <james.hogarth at gmail.com>

On 9 May 2015 04:29, "Paul R. Ganci" <ganci at nurdog.com> wrote:
>
> I have a system with two CentOS 7.1 guests. When I created the VMs I did
not have enough storage space in the default location
/var/lib/libvirt/images so I moved the default location to a directory
/home/vmimages. While this configuration is functional I regret creating a
new storage pool in /home. I would like to create a separate partition to
place the VM images removing them from their present /home/images location.
The /home partition is presently empty other than the VM images directory
so I can easily steal space from it (using only ~4% of 500GB). However, I
have a problem. Namely /home is an XFS file system so I cannot shrink the
partition in order to make space for the desired new VM images partition. I
was wondering if this procedure might work to do what I desire:
>
> 1.) Shutdown the VMs
> 2.) Archive the VM image directory /home/vmimages to a network drive
(don't have space locally other than on /home)
> 3.) Use parted or fdisk to delete present /home partition
> 4.) Use parted or fdisk to re-create smaller/home partition and new
/vm-images partition
> 5.) Create XFS file system on /home and /vm-images
> 6.) Extact VM image directory archive into /vm-images
> 7.) Use virt-manager to change default location of images to /vm-images
>
> Is there any chance that after all this the VMs would actually start up
again especially after a re-boot?
>

They are just disk images so as long as you don't mind deleting home then
this will work.

Don't forget to virsh edit each domain and update the paths in that.

In addition don't forget to fix your selinux contexts:

semanage fcontext -a -e /var/lib/libvirt/images /vm-images