By design, when you delete an object in MinIO, it isn’t immediately removed from disk — it’s simply marked as deleted.

In large-scale environments where numerous delete operations occur, this behavior can gradually consume disk space, even though the objects are no longer in use. Over time, you may notice that your available storage shrinks, despite regular deletions.

Adding more disks or nodes isn’t always a viable solution. So, what can you do?

To truly reclaim space, you need to permanently remove those deleted objects from disk.

To perform this procedure, we’ll use the mc (MinIO Client) command-line tool. We’ll assume it’s already configured, and we’ll be working with the prod alias and the test-bk bucket.

What Does “Marked as Deleted” Actually Mean?

When I say that an object is marked as deleted, it means the object isn’t truly removed from disk — it’s just hidden from normal view.

For example, if you try to list a deleted object, it seems like it’s gone:

[root@minio-prod-01 ~]# mc ls prod/test-bk/file.pdf
[root@minio-prod-01 ~]# 

However, if you list all versions of the object using the –versions flag, you’ll see something like this:

[root@minio-prod-01 ~]# mc ls --versions prod/test-bk/file.pdf
[2025-07-27 08:20:56 EEST]     0B STANDARD 6a2db261-173e-468a-89c4-c44f11d73c60 v2 DEL file.pdf
[2024-02-06 19:18:54 EET] 138KiB STANDARD 5997d305-af9e-4a2b-8c60-351c7f25c67d v1 PUT file.pdf

As you can see, there are two versions of the file:

  • v2 is a delete marker that tells MinIO the file should no longer appear in listings.
  • v1 is the original uploaded file.

Next, we need to tell MinIO after how much time it should permanently delete previous versions of a file (since a file can have multiple PUT versions), or the delete marker itself.

Step 1: Check for Existing Lifecycle Rules

First, let’s check if any lifecycle rule already exists for the bucket:

[root@minio-prod-01 ~]# mc ilm rule list prod/test-bk
mc: <ERROR> Unable to get lifecycle. The lifecycle configuration does not exist.
[root@minio-prod-01 ~]#

As shown above, there is currently no lifecycle configuration for the test-bk bucket.

Step 2: Add a Lifecycle Rule

Let’s create one:

[root@minio-prod-01 ~]# mc ilm rule add prod/test-bk --noncurrent-expire-days 1 --expire-delete-marker
Lifecycle configuration rule added with ID `d23k55ooo92f1l7cj1eg` to prod/test-bk.
[root@minio-prod-01 ~]#

What does this command do?

  • –noncurrent-expire-days 1: tells MinIO to expire all non-current versions of an object after 1 day.
  • –expire-delete-marker: instructs MinIO to also expire delete markers (so objects marked as deleted are permanently removed).

Step 3: Verify the Rule

[root@minio-prod-01 ~]# mc ilm rule list prod/test-bk
┌───────────────────────────────────────────────────────────────────────────────────────┐
│ Expiration for latest version (Expiration)                                            │
├──────────────────────┬─────────┬────────┬──────┬────────────────┬─────────────────────┤
│ ID                   │ STATUS  │ PREFIX │ TAGS │ DAYS TO EXPIRE │ EXPIRE DELETEMARKER │
├──────────────────────┼─────────┼────────┼──────┼────────────────┼─────────────────────┤
│ d23k55ooo92f1l7cj1eg │ Enabled │ -      │ -    │              0 │ true                │
└──────────────────────┴─────────┴────────┴──────┴────────────────┴─────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────┐
│ Expiration for older versions (NoncurrentVersionExpiration)                     │
├──────────────────────┬─────────┬────────┬──────┬────────────────┬───────────────┤
│ ID                   │ STATUS  │ PREFIX │ TAGS │ DAYS TO EXPIRE │ KEEP VERSIONS │
├──────────────────────┼─────────┼────────┼──────┼────────────────┼───────────────┤
│ d23k55ooo92f1l7cj1eg │ Enabled │ -      │ -    │              1 │             0 │
└──────────────────────┴─────────┴────────┴──────┴────────────────┴───────────────┘
[root@minio-prod-01 ~]#

Looks good — the lifecycle rule is now active.

Final Note

If you’re using a thin-provisioned LUN, you may also need to reclaim space on the VMware datastore and the underlying physical storage.
➡️ Continue reading the next section for details on space reclamation.

One Comment

Leave a Reply