Running fstrim occasionally?

Discussion in 'Server Operation' started by Taleman, Jan 7, 2021.

Tags:
  1. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    I noticed the dump of my virtual machine with 80 GB used disk was 148 GB (Proxmox, dump with Proxmox backup, discard on in proxmox disk settings). I experimented with fstrim, afterwards dump was 60 GB smaller. Reading discussions it seems fstrim should run about once a week even for rotating media.
    My virtual machine has Ext4 file system, the host has SSD disks where the image is stored. The fstrim only took 30 seconds so it is small load, and may go faster now that FS is almost trimmed.
    Any experiences with fstrim? Are you running it from cron and how often?
     
    ahrasis likes this.
  2. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    No experience here but following :)
     
  3. florian030

    florian030 ISPConfig Developer ISPConfig Developer

    i did not run fstrim by cron - i run this script from time to time:
    Code:
    #!/bin/bash
    PCT=/usr/sbin/pct
    for i in $($PCT list | grep running | awk '/^[0-9]/ {print $1}'); do
      $PCT exec $i -- bash -c "fstrim -a -v"
    done
    
     
    ahrasis likes this.
  4. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    I assume @florian030 runs that script on the Proxmox host computer? I run the fstrim on the quest virtual machine. I did not try running fstrim on the proxmox host, it might be better that way.
    I have thought having discard on in the virtual machine hard disk options would take care of zeroing the unused disk sectors. Now I think this is not the case, since the dump was much large than used disk space. So fstrim on the quest vm helps.
    Edit:
    I guess @florian030 uses containers for the quest machines, I have KVM virtual machines. In my case running the fstrim on the proxmox host may not be possible.
     
    ahrasis likes this.

Share This Page