trimforce - macOS


trimforce forces the file system to trim a given file or volume. Trimming reclaims unused disk space by identifying and removing unused blocks of data. This can improve drive performance and extend the lifespan of solid state drives (SSDs).


trimforce [options] path


  • -a, –all: Trim all volumes and filesystems
  • -f, –force: Force trimming even if the file or volume is busy
  • -i, –invalidate: Mark all blocks as invalid before trimming
  • -v, –verbose: Output progress information
  • –minimum-percent=: Only trim if the percent of free space on the volume is below the specified value


  • Trim the current working directory:
trimforce .
  • Trim all volumes and filesystems:
trimforce -a
  • Force trim a busy file:
trimforce -f busy.txt
  • Trim and invalidate all blocks on a specific volume:
trimforce -i /Volumes/MyVolume

Common Issues

  • “Error: Operation not permitted”: Ensure you have sufficient permissions to trim the file or volume.
  • “Error: Device is busy”: Use the -f option to force trimming even if the file or volume is busy.


trimforce can be used in conjunction with other macOS commands and tools for advanced disk management tasks. For example:

  • Combine with diskutil to trim specific volumes:
diskutil list | grep -v "NO NAME" | cut -d ' ' -f 1 | xargs -I{} trimforce /dev/disk{}
  • Create a maintenance script:
trimforce -a &> /dev/null
  • diskutil: Disk utility tool
  • fsck: File system check tool
  • smartctl: SMART disk monitoring tool