Turn on "Discard" option?

mn124700

Member
Feb 22, 2020
28
0
6
54
How important is it to turn on the "Discard" option for VMs when using an SSD drive for storage?

- Eric
 
If you have a storage underneath that supports thin provisioning and zeroing of unused space (ZFS, Ceph, I think thin LVM) then it helps to pass through the discard/trim commands to the actual storage to reclaim unused space.
 
Thanks Aaron, And this is regardless of which vm hard disk type is used (ide/scsi) of the guest vm?

So just to be clear, any vm I put on my zfs-raid mirror tank0 should have discard[x] enabled? and I assume ssd emulation.

What are the consequences of not doing this, the drive will fill up even if not full, how does one track this? Thanks for any explanation this is new to me.
 
So just to be clear, any vm I put on my zfs-raid mirror tank0 should have discard[x] enabled? and I assume ssd emulation.
I think SSD emulation isn't needed. But yes, if you use ZFS you should always have discard enabled. And remember that you also need to tell the guest OS to use discard.
What are the consequences of not doing this, the drive will fill up even if not full, how does one track this?
Yes, your virtual disks will grow and grow. You can use zfs list to view the zvols. If a zvol ist way bigger than the guest os is reporting used space, your discard might not be working.
 
Last edited:
  • Like
Reactions: entilza
ssd emulation is needed for virtual ide drive, to have discard working on some guest.
if you use virtio or virtio-scsi, you don't need ssd emulation, just enable discard.

Discard is use to free space on your physical storage, you delete a file inside a guest vm for example. without discard, when you delete a file, the space is still used on the the physical storage, so you can't use it in another vm.

(if you don't care about thin provisioning, you don't need discard)
 
I don’t use zfs but still notice drive space isn’t being reclaimed after deleting virtual disks. I detached then deleted but the space is still taken. What can I do to recover this space?
 
Try to run a fstrim -a on your host to do a manual discard of all mounted filesystems and look if it frees up stuff. If it works you really should enable discard for all your VMs and create a cronjob to run fstrim -a once a day. Like aaron already said, if you use ZFS/CEPH or LVMthin you need to manually setup discard everywhere.
 
  • Like
Reactions: Whitterquick
Try to run a fstrim -a on your host to do a manual discard of all mounted filesystems and look if it frees up stuff. If it works you really should enable discard for all your VMs and create a cronjob to run fstrim -a once a day. Like aaron already said, if you use ZFS/CEPH or LVMthin you need to manually setup discard everywhere.
Is this still needed with normal LVM? I never remember having to do this before, it would just free up the space instantly.
 
Its not needed with normal LVM if you got no thin provisioned LV but it would always be a good idea to enable TRIM/discard if you use SSDs because otherwise the garbage collection of the SSDs can't be optimal and it might reduce the life expectation and performance of your SSDs. SSDs work better the more free space they got. If you don't use discard the SSD won't delete stuff instantly.
 
Last edited:
Its not needed with normal LVM if you got no thin provisioned LV but it would always be a good idea to enable TRIM/discard if you use SSDs because otherwise the garbage collection of the SSDs can't be optimal and it might reduce the life expectation and performance of your SSDs. SSDs work better the more free space they got. If you don't use discard the SSD won't delete stuff instantly.
I understand that, I’m more concerned about it making the encryption more transparent. If I use discard with LVM will this still be the case, and do I still need to unlock with —allow discards?
 
Using discard will always weaken encryption. If you want a strong encryption you can use LVM without thin LVs and ignore the discard. SSDs will work without it and use garbage collection to manage deleted data but you will see a noticable performance impact. I for example really see that with veracrypt on windows. Raid0 of 4 SSDs and I get write speeds of 30-70 MB/s. Without encryption it was way above 1GB/s. At first it was still with encryption fast but the longer I used it, the slower it got.
 
Last edited:
  • Like
Reactions: Whitterquick
Using discard will always weaken encryption. If you want a strong encryption you can use LVM without thin LVs and ignore the discard. SSDs will work without it and use garbage collection to manage deleted data but you will see a noticable performance impact. I for example really see that with verascypt on winddows. raid0 of 4 SSDs and I get write speeds of 30-70 MB/s. Without encryption it was way above 1GB/s. At first it was still with encryption fast but the longer I used it, the slower it got.
That is a little worrying but I will see how it goes. Do you have VMs that you use as workstations? Like Remote Desktop sessions (Citrix style)?
 
That is a little worrying but I will see how it goes. Do you have VMs that you use as workstations? Like Remote Desktop sessions (Citrix style)?
I'm using 2 Win10 VMs. One for use as a HTPC connected via HDMI to my TV and the other one is for testing and stuff that won't run on linux/unix. But I only got 1 GPU, there are no free PCIe slots and without PCI passthrough of the GPU that Win10 VMs can'T even play a youtube video without stuttering. So I can only use one of the VMs at a time.
 
I'm using 2 Win10 VMs. One for use as a HTPC connected via HDMI to my TV and the other one is for testing and stuff that won't run on linux/unix. But I only got 1 GPU, there are no free PCIe slots and without PCI passthrough of the GPU that Win10 VMs can'T even play a youtube video without stuttering. So I can only use one of the VMs at a time.
Have you considered an external Gfx Card? (eGPU)
 
Have you considered an external Gfx Card? (eGPU)
The server got no Thunderbolt/USB3.1 and they would be way to expensive anyway. A 19W 20$ GPU would be just fine if you only want some hardware accelerated video decoding or offloading the GUI computation from the CPU. Just stupid that I bought the mATX board with only 3 PCIe slots and not the ATX version with 7 slots. I really could need 6 or 7 PCIe slots.
 
Last edited:
Using discard will always weaken encryption. If you want a strong encryption you can use LVM without thin LVs and ignore the discard. SSDs will work without it and use garbage collection to manage deleted data but you will see a noticable performance impact. I for example really see that with veracrypt on windows. Raid0 of 4 SSDs and I get write speeds of 30-70 MB/s. Without encryption it was way above 1GB/s. At first it was still with encryption fast but the longer I used it, the slower it got.
Hi you one of a very few guys that use veracrypt in a proxmox vm.
I have WD Gold HDD (no SSD, no Raid) which is fast as expected when using passthrough (virtio scsi) and no veracrypt.
I also get perfect performance using veracrypt if running on bare metal.
When I encrypt the passthrough disk with veracrypt write performance gets fucking lousy, 20-25 MB/s.
Do you have an idea why this happens?
the combination of veracrypt + passthrough semms not to do well.

This has nothing to do with the discard option.
 
Last edited:
Hi you one of a very few guys that use veracrypt in a proxmox vm.
I have WD Gold HDD (no SSD, no Raid) which is fast as expected when using passthrough (virtio scsi) and no veracrypt.
I also get perfect performance using veracrypt if running on bare metal.
When I encrypt the passthrough disk with veracrypt write performance gets fucking lousy, 20-25 MB/s.
Do you have an idea why this happens?
the combination of veracrypt + passthrough semms not to do well.

This has nothing to do with the discard option.
Did you enable the AES-NI flag in the VMs CPU options so it can make use of the AES accelleration needed for verycrapt?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!