apple / apple/containerization

[Request]: Storage - Automatically reclaim unused disk space from containers with minimal user interaction

Open
#414 3 comments 1 reaction 0 assignees View on GitHub
next storage
Dominant language
Swift
Stars
8.9k
Forks
359
Avg merge
2d 20h
Merged PRs (30d)
13

Description

### Feature or enhancement request details

Container disk images currently grow over time but never shrink. As containers create and delete data, freed blocks inside their filesystems are not automatically released to the host, leading to permanently increasing disk utilization. This results in wasted space for long-lived containers and unnecessary manual intervention to recover capacity.

To address this, we should automatically reclaim freed blocks from container filesystems using `fstrim` with minimal user interaction, this way users do not need to manually intervene or recreate containers to reclaim disk space.

Some implementation options:
* Online fstrim: Run `fstrim` while the container is active to release deallocated blocks to the host.
* Periodic cleanup: Execute `fstrim` periodically within `vminitd` for automated cleanup.
* Continuous discard: Mount filesystems with the `discard` option for continuous trimming.
* Manual offline shrink: Allow users to run `container shrink ` to launch a temporary VM, mount the image, run `fstrim` and shut down.

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.