---
title: "Proxmox LXC Disk Space Recovery via fstrim"
aliases: [proxmox-lxc-disk-trim, lxc-disk-cleanup, thin-provisioning-trim]
tags: [proxmox, lxc, storage, disk, fstrim, thin-provisioning]
sources:
  - "daily/2026-05-03.md"
created: 2026-05-03
updated: 2026-05-03
---

# Proxmox LXC Disk Space Recovery via fstrim

## The Problem

After deleting large files inside an LXC container, the disk usage shown in `df -h` (and Proxmox UI) does not decrease. This happens because deleting a file updates the filesystem's block map, but does **not** send a TRIM/discard command to the underlying thin-provisioned storage. The thin-provisioned volume still holds the blocks as allocated.

**Symptom:** LXC disk shows 99% used in Proxmox even after deleting hundreds of GB of files.

## Immediate Fix: Manual fstrim

Run inside the LXC container (or via `pct exec`):

```bash
pct exec <CTID> -- fstrim -av
# Example output:
# /: 64.3 GiB (69020286976 bytes) trimmed
```

This recovers space immediately. In one case: 99.39% → 35.80% after trim.

## Permanent Fix: Enable Automatic Discards

### 1. Storage-level: issue_discards in storage.cfg

Edit `/etc/pve/storage.cfg` on the Proxmox host and add `issue_discards 1` to the relevant storage pool:

```
lvmthin: local-lvm
    thinpool data
    vgname pve
    content rootdir,images
    issue_discards 1        ← add this line
```

This tells the LVM thin pool to pass discard operations through.

### 2. Weekly Cron (fallback)

If `issue_discards` causes performance concerns, run fstrim weekly instead:

```bash
# /etc/cron.weekly/fstrim-lxc
#!/bin/bash
for ctid in $(pct list | awk 'NR>1 {print $1}'); do
    pct exec "$ctid" -- fstrim -a 2>/dev/null
done
```

## Key Notes

- This only applies to **thin-provisioned** storage (LVM-thin, ZFS, Ceph). Thick-provisioned volumes don't benefit.
- `fstrim` is safe to run on live containers — it doesn't interrupt running processes.
- `issue_discards 1` should be set on the storage pool where LXC volumes live (usually `local-lvm`).

## Related Concepts

- [[wiki/concepts/proxmox-lxc-autostart]] — other Proxmox LXC configuration gotchas

## Sources

- [[daily/2026-05-03.md]] — LXC disk at 99.39% after Docker cleanup; `pct exec CTID -- fstrim -av` recovered space to 35.80%; permanent fix: `issue_discards 1` in storage.cfg
