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? Thanks. -- Paul (ganci at nurdog.com) (303)257-5208
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 didnot 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 upagain 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
On 05/08/2015 11:41 PM, James Hogarth wrote:> 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 >Thank you for the reminder. My monitor would have taken some verbal abuse but I would have figured it out eventually. :) -- Paul (ganci at nurdog.com) (303)257-5208
On 05/08/2015 11:41 PM, James Hogarth wrote:> 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 > 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 > 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.So it turns out this was even easier than I expected. The home partition was actually built upon LVM so some relatively simple use of LVM allowed me to do exactly what I wanted. However I have some very subtle issue that I don't understand. virt-manager, df and du incorrectly think this:> dfFilesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/centos_mric--srv2-root 52403200 5717192 46686008 11% / devtmpfs 16378220 0 16378220 0% /dev tmpfs 16388924 88 16388836 1% /dev/shm tmpfs 16388924 9224 16379700 1% /run tmpfs 16388924 0 16388924 0% /sys/fs/cgroup /dev/mapper/centos_mric--srv2-home 433378560 32928 433345632 1% /home /dev/sda1 508588 219764 288824 44% /boot /dev/mapper/centos_mric--srv2-vm--images 67858700 16294864 51563836 25% /vm-images> du -k /vm-images16261904 /vm-images But ls has it correct:> ls -alt /vm-imagestotal 16261908 -rw-------. 1 qemu qemu 51547734016 May 9 15:15 centos7.0-1.qcow2 -rw-------. 1 qemu qemu 12887130112 May 9 15:15 centos7.0.qcow2 drwxr-xr-x. 21 root root 4096 May 9 15:13 .. drwxr-xr-x. 2 root root 52 May 9 13:39 . Any idea how I make this correct? There are no side effects that I see but it is extremely puzzling to me as to why the new partition does not have the correct size. It appears the larger of the two VM images is not getting counted. -- Paul (ganci at nurdog.com) (303)257-5208
On 05/08/2015 08:28 PM, Paul R. Ganci wrote:> While this configuration is functional I regret creating a new storage > pool in /home.Out of curiosity, why?
On 05/10/2015 06:50 PM, Gordon Messmer wrote:> On 05/08/2015 08:28 PM, Paul R. Ganci wrote: >> While this configuration is functional I regret creating a new storage >> pool in /home. > > Out of curiosity, why?In part because this directory was getting in the way of synchronizing user directories between two servers. You could imagine the mess if I clobbered the /home/vmimages directories. I worked around the issue but felt that this pool just didn't belong in /home. I suppose that is mostly a personal choice but I am much happier now that the VM images are in their own space. Much less likely to make a nasty mistake. -- Paul (ganci at nurdog.com) (303)257-5208