Red Hat Training

A Red Hat training course is available for Red Hat Ceph Storage

Chapter 2. Block Device Commands

The rbd command enables you to create, list, introspect and remove block device images. You can also use it to clone images, create snapshots, rollback an image to a snapshot, view a snapshot, etc.

Important

To use Ceph Block Device commands, you must have access to a running Ceph cluster.

2.1. Prerequisites

To use Ceph Block Device commands on your client node, you will have to meet some prerequisites.

Follow Ceph Client Quick Start Guide to prepare your client node for rbd usage.

Important

The Ceph Client Quick Start Guide will also provide you information to mount and use block device on your client node. Please execute the steps on the client node only after creating an image for the block device in the Ceph Storage Cluster.

2.1.1. Access to the Storage Cluster

The client node where you will add a block device, also needs to have access to the Ceph Storage Cluster. To be able to access the cluster, the client node will need the cluster configuration file.

Execute from the admin node of the cluster:

ceph-deploy --overwrite-conf config push <client-node>

2.2. Creating a Block Device Image

Before you can add a block device to a node, you must create an image for it in the Ceph Storage Cluster first. To create a block device image, execute the following:

rbd create {image-name} --size {megabytes} --pool {pool-name}

For example, to create a 1GB image named foo that stores information in a pool named swimmingpool, execute the following:

rbd create foo --size 1024
rbd create bar --size 1024 --pool swimmingpool
Note

You must create a pool first before you can specify it as a source.

2.3. Listing Block Device Images

To list block devices in the rbd pool, execute the following (rbd is the default pool name):

rbd ls

To list block devices in a particular pool, execute the following, but replace {poolname} with the name of the pool:

rbd ls {poolname}

For example:

rbd ls swimmingpool

2.4. Retrieving Image Information

To retrieve information from a particular image, execute the following, but replace {image-name} with the name for the image:

rbd --image {image-name} info

For example:

rbd --image foo info

To retrieve information from an image within a pool, execute the following, but replace {image-name} with the name of the image and replace {pool-name} with the name of the pool:

rbd --image {image-name} -p {pool-name} info

For example:

rbd --image bar -p swimmingpool info

2.5. Resizing a Block Device Image

Ceph Block Device images are thin provisioned. They don’t actually use any physical storage until you begin saving data to them. However, they do have a maximum capacity that you set with the --size option. If you want to increase (or decrease) the maximum size of a Ceph Block Device image, execute the following:

rbd resize --image foo --size 2048

2.6. Removing a Block Device Image

To remove a block device, execute the following, but replace {image-name} with the name of the image you want to remove:

rbd rm {image-name}

For example:

rbd rm foo

To remove a block device from a pool, execute the following, but replace {image-name} with the name of the image to remove and replace {pool-name} with the name of the pool:

rbd rm {image-name} -p {pool-name}

For example:

rbd rm bar -p swimmingpool