[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
howtos:emulators:kvm_libvirt_qemu_quirks_tips_etc [2022/05/14 12:10 (UTC)] – created zeebrahowtos:emulators:kvm_libvirt_qemu_quirks_tips_etc [2023/11/05 20:50 (UTC)] (current) – [QEMU QCOW2 freed virtual disk space doesn't shrink image] zeebra
Line 30: Line 30:
  
 Then run grub-mkconfig -o /boot/grub/grub.cfg to make the change effective. Then run grub-mkconfig -o /boot/grub/grub.cfg to make the change effective.
 +
 +<note warning>Without modesetting, you will probably have to configure X manually to set the correct resolution. If you don't add nomodeset, only the "Linux splash" will set to the chosen resolution, but not the final console/framebuffer.</note>
 +\\
 +\\
 +\\
 +===== QEMU QCOW2 freed virtual disk space doesn't shrink image =====
 +
 +=== Background ===
 +
 +Let's say you have a faulty setup for the virtual disk and QCOW2 images. If everything was working (dicard/trim), when you delete things inside the virtual machine, the disk image should shrink to reflect this. If it doesn't work properly, the image will not shrink, even if you freed alot of space inside the virtual machine, the size of the image remains the same. QCOW2 is thinly provisioned, and will increase in size to refect the content inside the image, but it will not shrink unless there are the correct factors to do so. However, there is quick brilliant workaround for this issue.
 +
 +Always remember to have proper backups (backup your QCOW2 image before proceeding).
 +
 +=== How to manually shrink the QCOW2 image to reflect the content on the virtual disk image ===
 +
 +1. Inside the virtual machine, write zeroes to a file until the virtual disk is full. In a terminal:
 +<code>
 +dd if=/dev/zero of=/some/file
 +</code>
 +
 +2. Delete the new file (/some/file)\\
 +3. Shut down the virtual machine
 +
 +4. You can use the convert image function to basically move the current image into a new image (convert from qcow2 to qcow2), and it will reflect the actual size of content (throw away zeroes). In a terminal:
 +<code>
 +qemu-img convert -O qcow2 oldimage.qcow2 newimage.qcow2
 +</code>
 +
 +This is just a workaround. Ideally you should have your virtual machine setup with a functional discard inside the virtual machine to write zeroes to the areas of deleted files/content. If that works, the image will shrink when you delete files.
 +
 \\ \\
 \\ \\
Line 39: Line 69:
 \\ \\
 \\ \\
- 
  
  
 howtos:emulators:kvm_libvirt_qemu_quirks_tips_etc ()