Support secondary root directories (`secondary_roots`) for preloaded images, blobs, and snapshots
What is the problem you're trying to solve
In modern cloud environments, VM OS images (or attached read-only secondary disks) are preloaded with container images in /var/lib/containerd—including unpacked snapshots, content blobs, and BoltDB metadata.
However, when a VM is provisioned with a separate, high-performance ephemeral disk (such as an NVMe Local SSD RAID), containerd is typically configured to use this fast storage for optimal runtime performance. Because containerd currently cannot natively read preloaded state from secondary disks, the workaround is to copy gigabytes of preloaded data from the slower persistent boot disk to the fast ephemeral disk before starting containerd. This adds 30 to 40+ seconds to our startup latency.
Describe the solution you'd like
Allow containerd to use one primary directory (root) alongside one or more secondary directories (secondary_roots) so it can read preloaded images directly from secondary disks while writing all new images and running-
container changes to the fast primary disk.
Additional context
Example config.toml file
version = 3
root = "/mnt/ephemeral-ssd/containerd"
state = "/run/containerd"
# Optional top-level ordered list of secondary containerd root directories:
secondary_roots = [
"/var/lib/containerd-preload",
"/mnt/readonly-image-cache-disk"
] Duplicate root and secondary_roots
User can reference the same path in root and secondary_roots or reference the same path multiple times in secondary_roots. We will validate this and fail containerd startup.
BoltDB location
containerd keeps a single main writable BoltDB on the primary disk (root), and on startup it imports only the lightweight index entries (a few megabytes) from each secondary_root's database while leaving the
gigabytes of image files where they are.
Duplicate Content Precedence
Multiple data sources (root and one or more secondary_roots) may contain the same content blobs, snapshot layers, or mutable image tags. We can evaluate sources in strict priority order (root > secondary_roots[0] > secondary_roots[1] > ...) using first-match-wins.
Deletion
Kubelet garbage collector or user can delete an image preloaded in secondary disk. containerd removes its entry from the canonical BoltDB and deletes its backing blob and layer files from the secondary_root directory (just like a normal delete). If the secondary_root happens to be mounted on a read-only disk (returning EROFS), containerd skips deleting the files on disk and records a small "deleted" marker in the primary BoltDB so the image is not re-imported on future restarts.
Config changes or Disk is missing
The user can remove secondary_roots from config.toml or detach the disk from the VM. On every startup, containerd checks which secondary_roots are currently configured and reachable, and automatically removes database entries for any disk that was removed or detached. If a secondary_root disappears while containerd is already running, containerd detects that the files are gone and falls back to downloading the image normally onto the primary disk.
Source: containerd/containerd