There are two methods of issuing discards in Linux:

Online discard

  • Discard operations happen in real time whenever blocks are transitioned from used to free.
  • Enabled with the 'discard' mount option.

Periodic discard (Preferred Method)

  • Batch discard operations discard all unused blocks on mounted filesystems at regular intervals.
  • Enabled by systemd service or cron job. Consult your distribution’s documentation for setup instructions.

Note

  1. Your filesystem must support discard operations.
  2. You should use only one discard method at a time.