# How to Enable Image Cache in Block Storage

## Problem

Creating volumes from images can be slow, especially when the same image is used repeatedly. This can lead to increased I/O load and longer provisioning times. Enabling image caching in PCD's Block Storage (Cinder) service can significantly improve performance by storing a cached copy of frequently used images.

## Environment

* Private Cloud Director Virtualization - v2025.4 and Higher
* Private Cloud Director Kubernetes – v2025.4 and Higher
* Self-Hosted Private Cloud Director Virtualization - v2025.4 and Higher
* Self-Hosted Private Cloud Director Kubernetes - v2025.4 and Higher

## Procedure

1. Edit Cinder Backend Configuration: On the host where the Persistent Storage (or Cinder Volume) role is enabled, add the following parameters in the `[DEFULT]` section of the `/opt/pf9/etc/pf9-cindervolume-base/conf.d/cinder.conf`

```bash
image_volume_cache_enabled
image_volume_cache_max_count
image_volume_cache_max_size_gb
```

> Adjust `image_volume_cache_max_count` and `image_volume_cache_max_size_gb` based on the available disk space and use case.

For Example:

```bash
image_volume_cache_enabled = True
image_volume_cache_max_count = 50
image_volume_cache_max_size_gb = 200
```

> If NFS is configured as the backend for block storage, then do not enable image caching. Set `image_volume_cache_enabled = False` to avoid issues related to root disk sizing. (Known issue PCD-2623)

2. After updating the configuration, restart the `pf9-cindervolume-base` service for the changes to take effect:

```bash
$ sudo systemctl restart pf9-cindervolume-base
```

## Validation

**Check if Image Cache is Enabled:** Verify the effective configuration using the following command on the cinder node:

```bash
$ grep image_volume_cache _opt_pf9_etc_pf9-cindervolume-base_conf.d_cinder.conf
```

## Additional Information

What Each Parameter Means:

* `image_volume_cache_enabled`: Enables or disables the image caching mechanism.
* `image_volume_cache_max_count`: Limits the number of images to cache. If the limit is reached, the least recently used (LRU) image will be evicted.
* `image_volume_cache_max_size_gb`: Limits the total size (in GB) of all cached images. The LRU policy also applies here when the limit is hit.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://platform9.com/kb/pcd/image-library/how-to-enable-image-cache-in-block-storage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
