Disk discard option does not seem to be visible in Linux guest?


Nov 14, 2020
I have made a fresh PVE 6.3-6 installation using ZFS as filesystem. I created a VM and then enabled the `Discard` option. Then installed Ubuntu 20.04.

When I check it with `hdparm -I /dev/sda` there is nothing about TRIM mentioned in the output. The machine uses`VirtIO SCSI` and the disk is `scsi0` and I can see `discard=on` in `Hardware` tab of the VM settings.

Is this what others experience or something is wrong perhaps?

@Hannes Laimer I tried that and I can see the device is an SSD but there is no TRIM. See the VM config:

root@pve1:~# qm config 100
boot: order=scsi0;ide2;net0
cores: 2
ide2: none,media=cdrom
memory: 2048
net0: virtio=0E:CB:0A:E8:D0:AF,bridge=vmbr0,firewall=1
numa: 0
ostype: l26
scsi0: local-zfs:vm-100-disk-0,discard=on,size=32G,ssd=1
scsihw: virtio-scsi-pci
smbios1: uuid=f67a7625-e90c-4d12-a03e-e55b98f4d9ce
sockets: 1
vmgenid: c5d69f37-38b2-440a-b95f-f63b494822cb

if I check the disk in machine:
root@test:~# hdparm -I /dev/sda

SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

ATA device, with non-removable media
Likely used: 1
Logical max current
cylinders 0 0
heads 0 0
sectors/track 0 0
Logical/Physical Sector size: 512 bytes
device size with M = 1024*1024: 0 MBytes
device size with M = 1000*1000: 0 MBytes
cache/buffer size = unknown
IORDY not likely
Cannot perform double-word IO
R/W multiple sector transfer: not supported
DMA: not supported
PIO: pio0

root@test:~# smartctl -a /dev/sda
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.4.0-66-generic] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

Vendor: QEMU
Revision: 2.5+
Compliance: SPC-3
User Capacity: 34,359,738,368 bytes [34.3 GB]
Logical block size: 512 bytes
LU is thin provisioned, LBPRZ=0
Rotation Rate: Solid State Device
Device type: disk
Local Time is: Mon Mar 15 15:07:24 2021 UTC
SMART support is: Unavailable - device lacks SMART capability.

Current Drive Temperature: 0 C
Drive Trip Temperature: 0 C

Error Counter logging not supported

Device does not support Self Test logging
Just try an "fstrim -v /path" and see if it just works.

Tried those commands in a few VMs where TRIM works as expected and got no information regarding TRIM either.
Last edited:
  • Like
Reactions: yurtesen
Hmm interesting. I tried it and it actually seems to reduce the volume size.

But the question is, does the OS run it regularly even when the drive seemingly says it does not support TRIM? I guess time will tell :)
Depends on the OS inside the VM to run either discard or a periodic fstrim to push discards to the underlying storage. Typically Linux uses a systemd timer / cron job to run fstrim every few days and Windows usually schedules a weekly "disk optimization" task for the same purpose.

Running a sincronous "discard" on every delete implies at least twice the load on the storage, as every delete becomes at least two ops, one to delete the file and another to push the discard.


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 your own in 60 seconds.

Buy now!