[SOLVED] Fstrim lvm-thin clean the space

Ivan Gersi

Renowned Member
May 29, 2016
83
7
73
54
I have Windows VM machine virtualized from physical machine via virtio.
I had to reduce lvm size to 1TB because I use 2TB disk for migrating (physical server is only 1TB)

root@pve1:/dev/disk# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
data pve twi-aotz-- 1.67t 46.97 1.93
root pve -wi-ao---- 96.00g
swap pve -wi-ao---- <7.53g
vm-100-disk-1 pve Vwi-aotz-- 1000.00g data 80.34
There is one problem...I had about 600GB cams recording in the server, so I delete it and server has only 200GB/1000GB filled. But system still see 80% used capacity. E.g if backup of this machine has about 700GB instead 150GB. How can I clean this space?
--- Logical volume ---
LV Path /dev/pve/vm-100-disk-1
LV Name vm-100-disk-1
VG Name pve
LV UUID 5XDIJk-yljE-muc5-q9jW-NK7X-h0M5-ImYKoO
LV Write Access read/write
LV Creation host, time pve1, 2023-12-21 23:56:27 +0100
LV Pool name data
LV Status available
# open 1
LV Size 1000.00 GiB
Mapped size 80.34%
Current LE 256000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:7
I think I need to use fstrim, but I don`t know how.
When I tried to use fstrim how can I think there is error.
root@pve1:/# fstrim /dev/pve/vm-100-disk-1
fstrim: /dev/pve/vm-100-disk-1: not a directory
How can I need to use fstrim correctly?
 
Make sure the virtual disk got its "discard" checkbox enabled. Using "virtio block" is by the way not Windows best practice. This would be "virtio SCSI single" + "SCSI".

Then, in Windows, open your disk optimization window (you will find it in one of the settings tabs when right clicking a partition in the explorer) and tell it to optimize the disk.
There is also a powershell command you could google for trimming a partition.
 
Last edited:
I`vè already have changed scsi controller to default (instead virtio), so now I checked discard=on but I thought optimize must do node, not VM. Now, it seems good.
--- Logical volume ---
LV Path /dev/pve/vm-100-disk-1
LV Name vm-100-disk-1
VG Name pve
LV UUID 5XDIJk-yljE-muc5-q9jW-NK7X-h0M5-ImYKoO
LV Write Access read/write
LV Creation host, time pve1, 2023-12-21 23:56:27 +0100
LV Pool name data
LV Status available
# open 1
LV Size 1000.00 GiB
Mapped size 7.64%
Current LE 256000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:7
Thanks for explanation.
Solved
 

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!