Skip to main content
RunBook Academy

CephXV · CRUSH Maps and RulesCRUSH Maps and Rules

The replicated rule — the form you will write most often

Foundation⏱ ~15 mincephcrushtool

What you'll learn

  • Write a replicated CRUSH rule for a stated requirement
  • Create rules with the CLI rather than by editing the map
  • Verify a rule places as intended
  • Assign rules to pools and confirm the assignment

Prerequisites

None — start here.

Verified against Ceph Tentacle 20.2.x · Ceph Squid 19.2.x (supported previous) · cephadm matches the verified Ceph release · podman 4.x · csi-rbd and csi-cephfs current · RBD / CephFS / RGW current (matches Ceph release) · Linux kernel 5.15+ (5.10 minimum) · Ubuntu 24.04 LTS (Ceph host baseline) · Debian 12 (Bookworm) (Ceph host baseline) · Rocky Linux / RHEL / AlmaLinux 9.x (Ceph host baseline) · Proxmox VE 9.x (cross-course integration) · Kubernetes 1.31+ (cross-course integration) · 2026-08-18

Not yet marked complete on this device.

Why this matters in production

Nearly every pool on nearly every cluster uses a rule of this shape. Writing them correctly and verifying them is a small, frequently used skill.

The form

rule rack_replicated {
  id 1
  type replicated
  step take default
  step chooseleaf firstn 0 type rack
  step emit
}
LineMeaning
type replicatedthis rule is for replicated pools
step take defaultenter the tree at the default root
chooseleaf firstn 0 type rackpick size distinct racks, one OSD in each
step emitreturn the selection

Creating rules with the CLI

Hand-editing the map is unnecessary for standard rules:

NAME=acme
ROOT=root
FAILURE_DOMAIN=vm-db-01
CLASS=class
ceph osd crush rule create-replicated ${NAME} ${ROOT} ${FAILURE_DOMAIN} [${CLASS}]

ceph osd crush rule create-replicated rack_rule default rack
ceph osd crush rule create-replicated nvme_host default host nvme
ceph osd crush rule ls
ceph osd crush rule dump rack_rule

The CLI assigns the id, writes correct syntax, and cannot renumber existing rules — which is the main hazard of hand-editing.

Common variants

# host-level, the default
ceph osd crush rule create-replicated host_rule default host

# rack-level
ceph osd crush rule create-replicated rack_rule default rack

# NVMe only, host separation
ceph osd crush rule create-replicated nvme_rule default host nvme

# restricted to one rack (isolation, not redundancy)
ceph osd crush rule create-replicated racka_only rack-a host

The last is the one to use sparingly — it caps the pool at that subtree’s capacity permanently.

Verifying the outcome

PGID=12.1a
OSD=12
ceph osd pool get rbd-vms crush_rule
ceph pg ls-by-pool rbd-vms | head -5
ceph pg map ${PGID}
ceph osd find ${OSD} | jq '.crush_location'

Sample a few PGs and confirm the acting sets span the intended domains. Reading the rule shows the intent; reading the acting sets shows the result.

Quiz

Knowledge check · 4 questions

  1. Q1. Why should a replicated rule use firstn 0 rather than a literal count?

  2. Q2. Creating a CRUSH rule with the CLI immediately changes placement for existing pools.

  3. Q3. A new pool for a database workload must use NVMe only and survive a rack failure. Write and validate the rule.

    Cluster with 4 racks. NVMe OSDs exist in 8 hosts, spread 2 per rack. HDD OSDs are in all 24 hosts. The new pool db-pool will have size 3 and min_size 2. The team wants NVMe placement with rack-level separation and asks for the procedure end to end.

  4. Q4. Give the three-step procedure for adopting a new CRUSH rule and explain why they are separate.

Passing score: 75%. Answers are checked in this browser.

Production discipline

Create rules with ceph osd crush rule create-replicated rather than by hand-editing the map — the CLI writes correct syntax and cannot renumber existing rules, which is the main hazard of editing. Always validate with crushtool --test between creating and assigning, since that is the window in which being wrong costs nothing. And use firstn 0 in every replicated rule, because a hard-coded count silently undersizes every PG the day someone raises size.

Cross-course references

  • Ceph: Part XIII (CRUSH Fundamentals) for what the steps do.
  • Ceph: Part XVI (Device Classes) for class-aware rules.
  • Ceph: Part XVII (Pools) for assigning rules to pools.