TRIM in KVM VM on LVM and software raid?

JohnD

Renowned Member
Oct 7, 2012
83
12
73
Hello,

i have lvm running on top of a mdadm software raid 1 with two samsung 850pro SSDs.

As far as i know lvm and mdadm do support trim (i am using proxmox with kernel 3.10).

Does anybody know if and how i can trim my ext4 filesystems inside my kvm machines?

Thank you.
 
There is a discard=unmap option in the kvm manpage for the drive option itself. Maybe this works "by hard" if you pass your drive by hand in your vm.conf

If you want to do more "by hand" then you can use thin provisioned volumes in LVM like it is presented here:

http://dustymabe.com/2013/06/21/guest-discardfstrim-on-thin-lvs/

Only drawback: You need to recompile lvm2 and probably the kernel to use thin provisioned LVM volumes and will probably break something in proxmox or do everything by hand.
 
Only drawback: You need to recompile lvm2 and probably the kernel to use thin provisioned LVM volumes and will probably break something in proxmox or do everything by hand.

Correction: PVE does support this already:

root@pve ~ > lvm segtypes
striped
zero
error
free
snapshot
mirror
raid1
raid10
raid4
raid5
raid5_la
raid5_ra
raid5_ls
raid5_rs
raid6
raid6_zr
raid6_nr
raid6_nc
thin-pool
thin
root@pve ~ > uname -a
Linux pve 2.6.32-37-pve #1 SMP Wed Feb 11 10:00:27 CET 2015 x86_64 GNU/Linux
 
You need the 3.10 kernel.
The vm harddisk type has to be SCSI and under vm options you have to change the SCSI Controller Type to VIRTIO.
You can check trim support first on the host and than inside the vm with fstrim -v /
This setup works for me.

Regards, Oer2001
 
What do? if my KVM guest is Windows? it's dont work - "You need the 3.10 kernel. The vm harddisk type has to be SCSI and under vm options you have to change the SCSI Controller Type to VIRTIO."
 

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!