Score:0

How to recover host disk space? Lost with KVM running out of memory while adding and removing virtual disks wtih Virtual Machine Manager

fr flag

While using KVM and the Virtual Machine Manager, I discovered I was running out of disk space, while doing the following:

  1. Virtual Machine Manager, Details view, select VirtIO Disk 1, right click and select Add Hardware, enter a size.
  2. Run the VM and test.
  3. Shutdown the VM.
  4. Virtual Machine Manager, Details view, select VirtIO Disk 2, right click and select Remove Hardware.
  5. Virtual Machine Manager, Details view, select VirtIO Disk 1, right click and select Add Hardware, enter a different size.
  6. Run the VM and test.
  7. And repeat, removing the second virtual disk and adding a new one that is a different size.

After a while of doing this, host reports its running out of space and crashes. Aeigh! Maybe the removed virtual hardware did not also get deleted?

Rebooting, I deleted the VM using the Virtual Machine Manager and host seems happy but the disk is still pretty full. (and also Virtual Machine Manager was empty of all my other VMs (yikes!), but the list repopulated later - for anyone coming here with also that problem, hopefully this will be true for you, too. Also, virsh list gave nothing and still does, which made it extra scary).

How do I remove the unused virtual disks (if that is what is occupying the memory)?

Kyle H avatar
in flag
Check out the /var directory and use 'sudo du -sh /var/*' ad-infintium to discover what and where on the filesystem is taking up space. I use this command all the time for this, its handy. If you reply with whats taking up space I may be able to tell you how to fix things. My guess is that you arent deleting those disks youre creating from the pools in KVM
Insideup avatar
fr flag
I ran that line as suggested but saw nothing is out of the ordinary. For reference, I am looking for 100-200GB in new files. I also ran ```du -ah /home/.ecryptfs/ | sort -rn``` which listed very many /.Private/ECRYPTFS_FNEK_ENCRYPTED. files, starting at around 1020K (largest). I don't know if it is typical to have so many of these and if they are associated with KVM. Regardless, how would I go about deleting the disks I am creating with Virtual Machine Manager?
Insideup avatar
fr flag
@KyleH forgot to tag you in my response above
Kyle H avatar
in flag
Apologies, @Insideup, I wasn't clear enough. By ad infintium i meant keep running that command over and over to help narrow down where the files are that are taking the most space. For example, `du -sh /*` would show the sizes of the directories in the filesystem. Using this you can deduce which branch off root all your largest files are kept. Then, for example, if /var was where your largest files were then you would run `du -sh /var/*` to see all files/directories sizes off /var and then you could see the largest branch that way. Just keep following the breadcrumbs of that command :)
Insideup avatar
fr flag
@KyleH. Thank you for the additional explanation. I am confused as to why the Nautilus numbers for home indicate a different set of values than the terminal with ```du -sh /home/*``` , which shows 3x as much memory used up as indicated by Nautilus.
Kyle H avatar
in flag
The du command gives you the total accumulative space that files are taking up in the current directory, and all subdirectories inclusive. du is like disk used. taking folders for input, it gives you the total size of the current directory, and then all subdirectories sizes as well. nautilus likely just gives the size of the current folder you are in. hopefully that explains it better for you. I have trouble getting my thoughts through text because of a brain injury in 2007. please let me know if you need further clarification :) @Insideup
Insideup avatar
fr flag
@KyleH Brain injury sounds difficult. BTW, I would not have known. So I think you are right about the pools. ```du -shx /home/*``` output a larger size than totaling the contents with ```du -sx * | awk '{print $1}' | awk '{total+=$1} END{print total}' ```, which seems confusing. But I stumbled upon ```find . -type f -printf "%s\t%p\n" | sort -n | tail -10``` to list the 10 largest files, which output a list including several ```./.local/share/libvirt/images/VM_NAME.qcow2``` (which may be pools). So I am studying about pools now. Just wanted to update the thread and say thank you.
Score:0
fr flag

I was able to recover lost disk space in the following way:

In the Virtual Machine Manager:

  1. File > New Virtual Machine > Choose how you would like to install the operating system : Local install media > Choose ISO or CDROM install media and choose BROWSE.
  2. In default Filesystem Directory pane, I was able to delete unused qcow2 volumes by highlighting them and selecting the red "do not"-style button.

du -shx /home/* and checking Nautilus verified that disk space has been recovered.

In summary, if you are removing VirtIO disks in the Details view of your VM with Virtual Machine Manager, be sure to remove the unused qcow2 files in a separate action, as described above, in order to recover memory.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.