way to trim vm images

Ayush

Member
Oct 27, 2023
76
2
8
Hi Team,

We want to know if is there any way we can trim the images running of running vm in proxmox. We want to know when and where we can use virt-sparcify to remove images .

We have proxmox 8.1.4 with 3 node architecture and vm running on it.
 
We want to know if is there any way we can trim the images running of running vm in proxmox. We want to know when and where we can use virt-sparcify to remove images .
Depending on the used backend storage technology, sure, enable discard on the each virtual disk in PVE and refer to your OS manual how to trim. In Linux, this is fstrim -va. What backend storage technology do you use?
 
Thanks LnxBil , We are using Ceph as a storage (quency 17.2.7) and most of the vm running are linux/ Ubuntu OS.
 
Okay, then it should work after enabling discard for each virtual disk. If the aforementioned command returns a value, then it'll work, e.g. like this:

Code:
$ fstrim -va
/home: 361,7 MiB (379289600 bytes) trimmed on /dev/sdb1
/boot: 6 MiB (6290432 bytes) trimmed on /dev/sdc1
/: 536 MiB (561991680 bytes) trimmed on /dev/sdc2
 
  • Like
Reactions: Ayush
@LnxBil What if there is no output of the command ( fstrim -va) . What was wrong with the configuration. Even if I completed pre-requisite like SCSI controller as Virtio SCSI and enabled discard on disk ?
 
@LnxBil , Yes even after reboot it is not working on some of the vm's . There is a post which specifies that it if lsblk -D show 0B then it will not work.
 
@LnxBil , Yes even after reboot it is not working on some of the vm's .
Just to clearify: stop and start, reboot will not work.

There is a post which specifies that it if lsblk -D show 0B then it will not work.
Which post? It all boils down to having:
  • backend storage supporting thin provisioning
  • SCSI disk
  • virtio SCSI controller (single nor normal)
  • discard enabled on every disk
  • stop and start of the VM
  • guest support in the used FS and OS for TRIM (e.g. ext4 and a kernel newer than e.g. 8 years - number of years unknown but ballpark number)
 
@LnxBil I tried it but still on some vm are not working .
Backend storage : Ceph
virtio SCSI Controller :- Single
Discard is enabled
Stop and start the vm
I am attaching screenshot for your ref. VM file system is XFS.
How can I find this "guest support in the used FS and OS for TRIM "
 

Attachments

  • Screenshot from 2024-03-09 21-35-25.png
    Screenshot from 2024-03-09 21-35-25.png
    39.5 KB · Views: 15
Harddisk is virtio not scsi ... that could be the problem.
So with same setting which I shared with you was working on other vm but not with this one. Additionally what I observed that with new the vm where I am not able to run fstrim , the ssd emulation was disabled. And the vm to which I am able to run fstrim ssm emulation showing as option.
 

Attachments

  • Screenshot from 2024-03-09 23-39-17.png
    Screenshot from 2024-03-09 23-39-17.png
    20.6 KB · Views: 8
Maybe you need SSD to check if you're on virtio. Would you be on SCSI, it does not matter.
But that option is not available for some of the vm's. Even though I am not differentiating things in term of configuration part.
 
The option to set SCSI is always available. virtio SCSI is superior to just virtio disks. Consider changing this. Depending on the guest, you may need to install guest drivers (normally not necessary for Linux).
 
@LnxBil , What is the way to achieve it. Till now I added additional disk with SCSI controller to the existing vm. After that what need to be done to migrate existing disk to newly attached disk that is having SCSI .
 
@LnxBil , Thanks for your guidance . That really help me . I was able to release 1Tb of disk space.
So I disconnect the disk and reattach it using scsi after that I am able to run fstrim on it.
 
  • Like
Reactions: LnxBil

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!