Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Discard=Unmap on Virtio Disks

Featured Replies

I ran across an article whose author claimed that on recent versions of qemu,  discard=unmap was functional on virtio disks.  So I did some testing.

 

I have not run all permutations, but have tested:

  Unraid 6.9.2

  UEFI and Seabios VMs

  Q35-5.1 and i440fx-5.1 VMs

  Windows 10 and Windows 11 with the latest virtio drivers, virtio-win-0.1.196.iso

  Ubuntu 21.4

  raw and qcow2 vdisks

  vdisks on XFS and BTRFS disks

  vdisks with and without the copy-on-write attribute set

 

In all cases, the virtio disk was functionally equivalent to a virtio-scsi disk.  On file deletion, windows unmapped blocks immediately.  Linux unmapped blocks after running fstrim.

 

https://chrisirwin.ca/posts/discard-with-kvm-2020

Edited by aim60

Thanks for this!

  • 3 months later...

Thank you so much.

  • 1 month later...

Thank you for this nugget!

  • 2 years later...

Hello,

 

Doesn't work for me :(

 

Quote

<emulator>/usr/local/sbin/qemu</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback' discard='unmap'/>
      <source file='/mnt/user/domains/Gaming/vdisk1.img'/>
      <target dev='hdc' bus='virtio'/>
      <boot order='1'/>
      <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
    </disk>

image.png.305354cd1c2cc0977769a4167211f2a3.png
image.png.d1a6a784bb73108a4b4bfaef40b8d480.png

 

Can you help me ?

Edited by thymon

Did you run the Windows Defrag and Optimize drives after making the change?

Of course... :(

If you have the space copy the vdisk elsewhere, then copy back using cp --sparse=always, that will confirm if the vdisk growing is the problem. 

Ok, I'll try that.
I've free space in the Array.

 

thx

  • 1 year later...

does this work with qcow2?

I believe it can work with some limitations if the image was created with -o preallocation=off (sparse), but it won't work as well and as efficiently as with a raw image.

to understand better, I created the vm about a year ago, as a raw image, then converted to qcow2 for additional features, such as snapshots, now I activated discard unmap and did defragmentation but it is not working, I also tried to do cp sparse but without success, is there anything I can do?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.