Frequently Asked Question

rbd
Last Updated 3 hours ago

Using rbd to Manage Ceph Block Devices

rbd is the Ceph command‑line client for creating, configuring, and operating Ceph Block Devices (RBD images). It lets you treat object storage as block storage that can be attached to VMs, containers, or physical hosts.


1. Prerequisites

   ceph health status
  1. Ceph cluster health – ensure the cluster is HEALTH_OK.
  2. Authentication – you need a keyring entry with client capabilities (e.g., client.admin or a dedicated rbd client).
  3. Ceph CLI installed – on the host where you’ll run rbd.

2. Creating an RBD Image

Step Command Explanation
2.1 rbd pool list Show available pools. Choose the pool where the image will reside (e.g., rbd).
2.2 rbd create / --size --image-feature layering Create a new image. --size is in GiB; --image-feature layering enables thin provisioning and snapshots.
2.3 Verify creation rbd info /

Example

rbd create images/backup01 --size 50 --image-feature layering
rbd info images/backup01

Output (truncated):

name: images/backup01
size: 53687091200
usage: 0
format: 2
features: layering

3. Resizing an RBD Image

Step Command Notes
3.1 rbd resize /name> size> is in GiB. The image must be closed (no active snapshot or active client) before resizing.
3.2 (Optional) Re‑open if needed After resize, you can re‑open the image for use.

Example

rbd resize images/backup01 75   # increase to 75 GiB
rbd resize images/backup01 -- -20   # decrease to 20 GiB (must be closed)

If you receive “image is in use”, close all snapshots or unmount the block device first.


4. Managing Snapshots

4.1 Create a Snapshot

rbd snap create /@

Example:

rbd snap create images/backup01@daily-2024-10-01

4.2 List Snapshots

rbd snap ls /

4.3 Roll Back to a Snapshot

rbd rollback /@

Rollback makes the snapshot the active data set; the current data becomes a new snapshot.

4.4 Delete a Snapshot

rbd snap rm /@

4.5 Delete All Snapshots (except latest)

rbd snap trim /

Only removes snapshots that are no longer referenced.


5. Cloning an Image

Clones are writable copies that share data with the source until modified (copy‑on‑write). Useful for test environments.

rbd clone /@ /

Example

rbd clone images/backup01@daily-2024-10-01 images/backup01-clone

To delete a clone: rbd delete /.


6. Attaching an RBD Image to a Host

6.1 Map the Image

rbd map /

The command returns a block device path, e.g., /dev/rbd0.

6.2 Format (if needed)

mkfs.ext4 /dev/rbd0

6.3 Mount the Device

mkdir -p /mnt/rbd
mount /dev/rbd0 /mnt/rbd

6.4 Unmap when finished

rbd unmap /dev/rbd0

For production use, consider using ceph-fuse or rbd-nbd for network‑block device access.


7. Common Troubleshooting

Symptom Check Fix
rbd: command not found Ceph CLI installed? apt-get install ceph (Debian/Ubuntu) or yum install ceph (RHEL).
rbd: cannot open image Image not exists or not in correct pool Verify with rbd ls ; create if missing.
resize failed: image is in use Image has active snapshots or is mapped Close snapshots (rbd snap ls), unmap (rbd unmap).
Permission denied Keyring lacks allow r/allow w Add capabilities: ceph auth get client. and edit keyring or create a new client with proper caps.

8. Quick Reference Cheat Sheet

# List pools
rbd pool list

# Create image (50 GiB, layering enabled)
rbd create images/backup01 --size 50 --image-feature layering

# Show image info
rbd info images/backup01

# Resize to 75 GiB
rbd resize images/backup01 75

# Create snapshot
rbd snap create images/backup01@daily-2024-10-01

# List snapshots
rbd snap ls images/backup01

# Roll back to snapshot
rbd rollback images/backup01@daily-2024-10-01

# Delete snapshot
rbd snap rm images/backup01@daily-2024-10-01

# Clone from snapshot
rbd clone images/backup01@daily-2024-10-01 images/backup01-clone

# Map image (get /dev/rbdX)
rbd map images/backup01

# Unmap image
rbd unmap /dev/rbdX

9. Where to Find More Information

  • Ceph Documentation
  • Man pageman rbd on any Ceph client host.

Remember: Always test resize or snapshot operations on a non‑production image first, and keep regular backups of critical RBD data.

This FAQ was generated and/or edited by GAIN, GENs Artificial Intelligence Network and should not be considered 100% accurate. Always check facts and do your research, things change all the time. If you are unsure about any information provided, please raise a support ticket for clarification.

This website relies on temporary cookies to function, but no personal data is ever stored in the cookies.
OK
Powered by GEN UK CLEAN GREEN ENERGY

Loading ...