Site icon New Generation Enterprise Linux

Don’t let LVM starve your SSD of trims

Filesystem & Storage (ZFS/Btrfs/LVM)

Don’t let LVM starve your SSD of trims

Technical Briefing | 10/31/2026

Okay, let’s talk about something that’s probably been gnawing at your servers without you even realizing it. You’ve got LVM, maybe thin pools for your VMs or containers, sitting on top of some shiny SSDs or NVMe drives. You’ve done the right thing: you’ve enabled fstrim on a cron job, or maybe even put discard in fstab. You think you’re golden, right? Your drives are getting trimmed, performance should be steady. But then, a few months down the line, write latency starts creeping up, especially for those thin-provisioned LVs. Things just feel sluggish. This has definitely bitten me in prod more than once, and it’s a hell of a thing to debug when the obvious stuff checks out.

The Hidden Layers: Why your trims aren’t getting through

Here’s the deal: fstrim or the discard mount option tells the filesystem to tell the underlying block device that certain blocks are no longer in use and can be zeroed out. When that underlying block device is a physical SSD, great. But when you introduce LVM into the mix, especially with features like thin provisioning or even just a plain old logical volume, LVM itself becomes that “underlying block device” from the filesystem’s perspective. And LVM, by default, isn’t always configured to pass those discard requests down to the actual physical drive. It just absorbs them, shrugs, and carries on. The blocks are marked free within the LVM layer, sure, but the physical NAND cells on your SSD never get told they can be wiped. That leads to higher write amplification, wear, and eventually, degraded performance as the drive has to juggle more dirty blocks.

# Check if an LVM thin pool or LV is set to issue discards.
# Look for "Discards" line. If "Issue Discards" is "no", it's not passing them.
lvdisplay -o +discards /dev/vg_data/lv_thinpool


# To enable discard passthrough for an LV (or thin pool itself)
# Be careful: this is usually synchronous and can hit performance.
# Better for manual fstrim or background LVM discards.
lvchange --issue-discards y /dev/vg_data/lv_thinpool


# Alternatively, modify lvm.conf to enable by default for LVs/thin pools:
# Change "issue_discards = 0" to "issue_discards = 1" in lvm.conf
# This is a global setting and applies to newly created LVs.
# But for existing ones, you'll still need lvchange.

Making LVM Play Nicely: issue_discards and its nuances

  • Synchronous Pain: If you enable issue_discards directly on an LV or thin pool and the filesystem above it uses the discard mount option, those discards become synchronous. Every time the filesystem frees a block, LVM immediately tries to pass that discard down. This can introduce significant I/O latency.
  • Asynchronous is usually better: For most production workloads, you’re usually better off with fstrim running periodically (daily/weekly) combined with LVM’s issue_discards being enabled. This way, discards are batched and processed during off-peak times, reducing the immediate performance hit.
  • Thin Pool Specifics: For thin pools, issue_discards is critical. If not enabled, the space freed up by a guest VM (even if it fstrims its own filesystem) won’t be passed down to the underlying physical device, nor will it be marked as free within the thin pool for reuse. It’s a double whammy.
  • Security Angle: Discarding blocks effectively zeroes them out from the drive’s perspective. If you rely on data recovery forensics, issue_discards makes that harder. Make sure you understand the implications for your data retention policies.

The lvm.conf file, usually in /etc/lvm/lvm.conf, has a issue_discards = 0 setting by default. That’s the main culprit for most fresh installs. Flipping that to 1 is a good start for new LVs and thin pools, but existing ones will need lvchange –issue-discards y applied to them individually. Don’t just enable issue_discards and then slap discard on every fstab entry. You’ll likely regret the performance hit unless you absolutely need instant, synchronous block reclamation. My advice: use fstrim regularly on your filesystems, and make sure issue_discards is enabled on the LVs and thin pools so those batched trim requests can actually reach the physical hardware. And always monitor lsblk –discard before and after running fstrim to make sure those DISC-GRAN and DISC-MAX values are actually changing.

This isn’t just theoretical optimization. It’s about keeping your I/O performance consistent over the long haul, extending the life of your expensive SSDs, and preventing those mysterious slowdowns that make you tear your hair out. It’s one of those silent configuration bits that can make or break your storage performance, and it’s almost never covered in the “get started with LVM” tutorials. Now you know.

Linux Admin Automation  |  © www.ngelinux.com  |  10/31/2026
0 0 votes
Article Rating
Exit mobile version