Unmap/trim operation doesn't reclaim the space on linux vms
search cancel

Unmap/trim operation doesn't reclaim the space on linux vms

book

Article ID: 396655

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

  • There will be huge difference in the space usage in guest Os and VMDK level
  • All the disks are thin provisioned
  • In the guest logs you will see the events fstrim requests are getting rejected in hypervisor

  • Below error is also observed when fstrim was ran
    [root@xxxx]fstrim /backup 
    FITRIM ioctl failed: Input/output error

Environment

VMware vSphere Esxi (All Versions)

Cause

If the VM hardware version is below 13, "write same with UNMAP" will be unsupported. In this case, the guest operating system will abort fstrim commands as the requests will be discarded by the Hypervisor.

The following command should be executed inside the guest on the specific disk where fstrim previously failed.

[root@xxxxx~]$  sg_vpd -vvvv -p lbpv /dev/sdc
found bsg_major=248
open /dev/sdc with flags=0x800
inquiry cdb: 12 01 b2 00 fc 00
duration 0 ms
Logical block provisioning VPD page (SBC):
[PQual=0 Peripheral device type: disk]
Write same (16) with unmap bit supported (LBWS): 0<--------This should be 1


Resolution

  • The VM hardware version should be upgraded to version 13 or higher for "write same" to be supported on Linux VMs. (Note: the VM must be powered off to perform the hardware upgrade.)
  • Once upgraded, "write same" with the UNMAP bit will appear as supported. Running the fstrim command will then complete successfully, allowing space to be reclaimed on the VMDK.