rbd
The rbd
(RADOS Block Device) command-line tool is used to manage block devices in a Ceph storage cluster. RADOS Block Devices (RBD) are block storage volumes backed by the Ceph distributed object store. These can be used for cloud infrastructure, virtual machines, or other applications that need block storage.
Here’s a detailed overview of common rbd
subcommands and their usage:
General Structure of rbd
Command
rbd
Command[options]
: Global options such as--pool
,--cluster
, etc.<subcommand>
: The specific operation or management action to be performed (e.g.,create
,info
,rm
).[arguments]
: Additional arguments required by the subcommand.
Common rbd
Subcommands
rbd
Subcommands1. Image Management
rbd create
rbd create
Creates a new RADOS Block Device (RBD) image.
Example:
This creates a new image named myimage
of size 10 GB.
rbd rm
rbd rm
Removes a specified RBD image from a pool.
Example:
This deletes the image myimage
from the pool.
rbd info
rbd info
Displays information about an RBD image, such as size, object size, features, etc.
Example:
This shows detailed information about the image myimage
.
rbd resize
rbd resize
Resizes an existing RBD image.
Example:
This resizes the myimage
to 20 GB.
2. Image Listing and Mapping
rbd ls
rbd ls
Lists all RBD images in a specified pool.
Example:
This lists all RBD images in the default pool or the specified pool.
rbd map
rbd map
Maps an RBD image to a block device on the local system.
Example:
This maps the image myimage
to a block device (e.g., /dev/rbd0
) on the local system.
rbd unmap
rbd unmap
Unmaps an RBD image from the local system.
Example:
This unmaps the block device /dev/rbd0
.
3. Image Snapshot Management
rbd snap create
rbd snap create
Creates a snapshot of an RBD image.
Example:
This creates a snapshot mysnap
of the image myimage
.
rbd snap ls
rbd snap ls
Lists all snapshots for a given image.
Example:
This lists all snapshots of the image myimage
.
rbd snap rollback
rbd snap rollback
Rolls back an image to a specific snapshot.
Example:
This rolls back the image myimage
to the snapshot mysnap
.
rbd snap rm
rbd snap rm
Removes a specific snapshot.
Example:
This removes the snapshot mysnap
from the image myimage
.
4. Image Cloning
rbd clone
rbd clone
Clones an RBD image from a snapshot to create a new image.
Example:
This creates a new image myimage-clone
as a clone of the snapshot mysnap
from the image myimage
.
5. Layering and Caching
rbd feature disable
rbd feature disable
Disables specific features (e.g., layering) on an RBD image.
Example:
This disables the layering
feature for the image myimage
.
rbd feature enable
rbd feature enable
Enables specific features (e.g., layering) on an RBD image.
Example:
This enables the layering
feature for the image myimage
.
6. Export and Import
rbd export
rbd export
Exports an RBD image to a file.
Example:
This exports the myimage
to a file named myimage_export.raw
.
rbd import
rbd import
Imports an image from a file into an RBD image.
Example:
This imports the image from myimage_export.raw
and stores it as a new image myimage
in the pool.
rbd import-diff
rbd import-diff
Applies incremental differences to an RBD image from a file (created by rbd export-diff
).
Example:
This applies incremental changes to the myimage
from the file myimage_diff
.
7. Advanced Operations
rbd lock add
rbd lock add
Adds a lock to an image, which prevents other clients from modifying the image.
Example:
This adds a lock on the myimage
, preventing modification by other clients.
rbd lock remove
rbd lock remove
Removes a lock from an image.
Example:
This removes the lock on the myimage
with the specific lock ID and locker ID.
rbd du
rbd du
Displays disk usage information for a specific RBD image.
Example:
This shows how much space is being used by the myimage
.
rbd bench
rbd bench
Performs a benchmark test on an RBD image.
Example:
This performs a benchmark test with 4 MB write I/O operations on myimage
for a total of 1024 MB.
Conclusion
The rbd
command provides extensive tools for managing block devices in Ceph, including creating, listing, resizing, and removing RBD images. You can also perform advanced operations like snapshots, cloning, exporting, and importing, as well as setting up features like layering. Mastering the rbd
tool enables fine control over RADOS Block Devices, making it an essential skill for managing block storage in Ceph-based environments.
Last updated