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 Commandrbd [options] <subcommand> [arguments][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 createCreates a new RADOS Block Device (RBD) image.
rbd create <image-name> --size <size-in-MB|GB|TB> [options]Example:
rbd create myimage --size 10G
This creates a new image named myimage of size 10 GB.
rbd rm
rbd rmRemoves a specified RBD image from a pool.
Example:
This deletes the image myimage from the pool.
rbd info
rbd infoDisplays information about an RBD image, such as size, object size, features, etc.
Example:
This shows detailed information about the image myimage.
rbd resize
rbd resizeResizes an existing RBD image.
Example:
This resizes the myimage to 20 GB.
2. Image Listing and Mapping
rbd ls
rbd lsLists all RBD images in a specified pool.
Example:
This lists all RBD images in the default pool or the specified pool.
rbd map
rbd mapMaps 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 unmapUnmaps an RBD image from the local system.
Example:
This unmaps the block device /dev/rbd0.
3. Image Snapshot Management
rbd snap create
rbd snap createCreates a snapshot of an RBD image.
Example:
This creates a snapshot mysnap of the image myimage.
rbd snap ls
rbd snap lsLists all snapshots for a given image.
Example:
This lists all snapshots of the image myimage.
rbd snap rollback
rbd snap rollbackRolls back an image to a specific snapshot.
Example:
This rolls back the image myimage to the snapshot mysnap.
rbd snap rm
rbd snap rmRemoves a specific snapshot.
Example:
This removes the snapshot mysnap from the image myimage.
4. Image Cloning
rbd clone
rbd cloneClones 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 disableDisables specific features (e.g., layering) on an RBD image.
Example:
This disables the layering feature for the image myimage.
rbd feature enable
rbd feature enableEnables 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 exportExports an RBD image to a file.
Example:
This exports the myimage to a file named myimage_export.raw.
rbd import
rbd importImports 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-diffApplies 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 addAdds 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 removeRemoves a lock from an image.
Example:
This removes the lock on the myimage with the specific lock ID and locker ID.
rbd du
rbd duDisplays disk usage information for a specific RBD image.
Example:
This shows how much space is being used by the myimage.
rbd bench
rbd benchPerforms 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