Disk Cleanup in Appliance Upgrade Process

Overview

Trimming Unused Blocks on the Filesystem

Changing the Schedule

Additional Resources

Overview

This feature helps reduce excessive disk usage on the Appliance disk. Two factors contribute to this issue:

  • Old Docker images that are no longer in use but remain stored.
  • Unused blocks on a mounted filesystem.

To prevent unnecessary disk usage, old Docker images are cleaned up during each Login Enterprise update, just before you're prompted to confirm the Debian update.

Frame 868.png

Trimming Unused Blocks on the Filesystem

To address the second issue, unused blocks on the mounted filesystem, you can use the fstrim command. This trims the disk and discards blocks that are no longer in use by the mounted filesystem.

The device underlying the file system must support physical discard operations. To check if it does, ensure the value in the /sys/block/{device_name}/queue/discard_max_bytes file is not zero. The script used for this implementation will verify this before performing the trim operation.

Important: Running fstrim too frequently can reduce the lifespan of lower-quality SSDs. For most desktop and server systems, trimming once a week is sufficient.

Changing the Schedule

The script checks for support of discard operations and, if not already enabled, sets up a system timer for weekly trimming (scheduled by default for Mondays at 12 PM UTC). If you prefer a custom schedule, you can modify it by editing the fstrim.timer file:

nano /lib/systemd/system/fstrim.timer

Frame 870.png

Frame 871.png

The timer is set during the initial run startup and is configured to UTC, ensuring it applies both after updates and for new deployments.

If the timer hasn’t been enabled yet, the script will perform the first trim automatically. This ensures the initially scheduled trim doesn’t interfere with testing results (it might execute while testing is in progress). For optimal results, it’s best to run the first trim before any services are running, which allows subsequent scheduled trims to be completed more quickly.

Frame 869.png

This feature runs quietly in the background. It’s fast, requires no user interaction, and doesn’t cause disruptions. The only indication that cleanup has occurred is through terminal messages and log entries. Response text from cleaning up old Docker images is logged to the loginvsi/update.log file, and filesystem trimming output can be found in the loginvsi/startup.log file.

Frame 872.png

Additional resources