[SOLVED] # fstrim / fstrim: /: the discard operation is not supported

RobFantini

Famous Member
May 24, 2012
2,023
107
133
Boston,Mass
hello
using ceph and local zfs ,

with kvm's with discard set in pve, fstrim does not work.
I get:
Code:
# fstrim /
fstrim: /: the discard operation is not supported

/etc/fstab has:
Code:
UUID=string  / ext4 rw,relatime,nobarrier,data=ordered,errors=remount-ro 0 1

kvm config:
Code:
virtio0: ceph-kvm:vm-2118-disk-1,discard=on,size=8G


I thought I read on pve wiki that discard / trim would work on zfs and ceph.

Is fstrim supposed to work? II may have something set up incorrectly.
 
Last edited:
Mir - thank you for the answer.

when using the pve web interface:
It does not look like it is possible to choose or switch to virtio-scsi ?
 
with what I see here, for ceph and zfs there is not an option on pve to choose scsi.

I'll test by creating a new kvm. probably there is something I'm missing.
 
so fstrim works with the new ceph kvm.

the difference is the new new one has scsi not virtio:
Code:
# grep ceph-kvm *
101.conf:scsi0: ceph-kvm:vm-101-disk-1,discard=on,size=4G
102.conf:virtio0: ceph-kvm:vm-102-disk-1,discard=on,size=5G
114.conf:virtio0: ceph-kvm:vm-114-disk-1,discard=on,size=8G
2118.conf:virtio0: ceph-kvm:vm-2118-disk-1,discard=on,size=8G

the old kvm's were moved to ceph from other storage.

I'll test editing the .conf files one at a time and rebooting..
 
so fstrim works with the new ceph kvm.

the difference is the new new one has scsi not virtio:
Code:
# grep ceph-kvm *
101.conf:scsi0: ceph-kvm:vm-101-disk-1,discard=on,size=4G
102.conf:virtio0: ceph-kvm:vm-102-disk-1,discard=on,size=5G
114.conf:virtio0: ceph-kvm:vm-114-disk-1,discard=on,size=8G
2118.conf:virtio0: ceph-kvm:vm-2118-disk-1,discard=on,size=8G

the old kvm's were moved to ceph from other storage.

I'll test editing the .conf files one at a time and rebooting..

Doing the edit will technically work fine, however changes from VDA to SDA within the OS, so may cause issues.
 
On existing vm you can change in gui.
  1. Stop vm
  2. Hardware tab select disk you want to change and remove it. It will not delete the disk it removes it from the running vm and will be listed as an unused disk in hardware tab. Just be sure not to press remove the whole vm button!
  3. Double click unused disk, set options
  4. If you changed a boot disk go to options tab and fix the boot order.
 
hello all - thank you for the help!
yea I'll just use cli, delete and re add is the last resort.
so far changing the boot order was needed.
for our 40 debian vm's - they all use uuid not vda etc so that makes that part easy.

do you think windows will need adjustments? we just have 2 of those things.
 
When changing windows boot disks I have had luck with this process:

  1. Shutdown widows
  2. Add a temporary disk of the new type
  3. Start windows
  4. Install driver for new controller
  5. Shutdown windows
  6. Change boot disk to new type
  7. Start windows
I've not tried virtio scsi on windows so no idea if that even world's ok or not.
 
When changing windows boot disks I have had luck with this process:

  1. Shutdown widows
  2. Add a temporary disk of the new type
  3. Start windows
  4. Install driver for new controller
  5. Shutdown windows
  6. Change boot disk to new type
  7. Start windows
I've not tried virtio scsi on windows so no idea if that even world's ok or not.
It works just fine for VirtIO Scsi too. I just did that 2 days ago,
 
I had the same problem. I have PVE 6.2. Disks are set up with VirtIO Block. There's "Discard" option but adding it didn't change the error message.

I got it fixed this way:
- shut down VM Edit: not needed :)
- mount the disk inside PVE
- issue fstrim command on the mounted drive

If you have disk with partitions, use 'kpartx -av /dev/poolname/diskname' and mount from /dev/mapper/...

Edit:
- if you use volume as a filesystem, Discard option doesn't work
- if you use volume as a disk, then Discard option works
 
Last edited:

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!