2019-07-19 13:44:44 +00:00
|
|
|
|
=============================
|
|
|
|
|
Basic Block Device Commands
|
|
|
|
|
=============================
|
2013-06-14 23:56:58 +00:00
|
|
|
|
|
|
|
|
|
.. index:: Ceph Block Device; image management
|
2012-09-18 18:41:32 +00:00
|
|
|
|
|
2024-03-18 04:11:10 +00:00
|
|
|
|
The ``rbd`` command enables you to create, list, inspect and remove block
|
2012-05-31 22:35:33 +00:00
|
|
|
|
device images. You can also use it to clone images, create snapshots,
|
|
|
|
|
rollback an image to a snapshot, view a snapshot, etc. For details on using
|
|
|
|
|
the ``rbd`` command, see `RBD – Manage RADOS Block Device (RBD) Images`_ for
|
|
|
|
|
details.
|
|
|
|
|
|
2013-06-14 23:56:58 +00:00
|
|
|
|
.. important:: To use Ceph Block Device commands, you must have access to
|
|
|
|
|
a running Ceph cluster.
|
|
|
|
|
|
2017-06-26 13:48:00 +00:00
|
|
|
|
Create a Block Device Pool
|
|
|
|
|
==========================
|
|
|
|
|
|
2022-12-06 13:14:49 +00:00
|
|
|
|
#. Use the ``ceph`` tool to `create a pool`_.
|
2017-06-26 13:48:00 +00:00
|
|
|
|
|
2022-12-06 13:14:49 +00:00
|
|
|
|
#. Use the ``rbd`` tool to initialize the pool for use by RBD:
|
2017-06-26 13:48:00 +00:00
|
|
|
|
|
2022-12-06 13:14:49 +00:00
|
|
|
|
.. prompt:: bash $
|
|
|
|
|
|
|
|
|
|
rbd pool init <pool-name>
|
|
|
|
|
|
|
|
|
|
.. note:: The ``rbd`` tool assumes a default pool name of 'rbd' if no pool
|
|
|
|
|
name is specified in the command.
|
2017-06-26 13:48:00 +00:00
|
|
|
|
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2017-07-07 14:41:07 +00:00
|
|
|
|
Create a Block Device User
|
|
|
|
|
==========================
|
|
|
|
|
|
2022-12-06 14:20:24 +00:00
|
|
|
|
Unless otherwise specified, the ``rbd`` command uses the Ceph user ID ``admin``
|
|
|
|
|
to access the Ceph cluster. The ``admin`` Ceph user ID allows full
|
|
|
|
|
administrative access to the cluster. We recommend that you acess the Ceph
|
|
|
|
|
cluster with a Ceph user ID that has fewer permissions than the ``admin`` Ceph
|
|
|
|
|
user ID does. We call this non-``admin`` Ceph user ID a "block device user" or
|
|
|
|
|
"Ceph user".
|
2017-07-07 14:41:07 +00:00
|
|
|
|
|
2022-12-06 14:20:24 +00:00
|
|
|
|
To `create a Ceph user`_, use the ``ceph auth get-or-create`` command to
|
2022-12-07 14:43:31 +00:00
|
|
|
|
specify the Ceph user ID name, monitor caps (capabilities), and OSD caps
|
|
|
|
|
(capabilities):
|
2017-07-07 14:41:07 +00:00
|
|
|
|
|
2022-12-06 14:20:24 +00:00
|
|
|
|
.. prompt:: bash $
|
2017-07-07 14:41:07 +00:00
|
|
|
|
|
2022-12-06 14:20:24 +00:00
|
|
|
|
ceph auth get-or-create client.{ID} mon 'profile rbd' osd 'profile {profile name} [pool={pool-name}][, profile ...]' mgr 'profile rbd [pool={pool-name}]'
|
2017-07-07 14:41:07 +00:00
|
|
|
|
|
2022-12-07 14:43:31 +00:00
|
|
|
|
For example: to create a Ceph user ID named ``qemu`` that has read-write access
|
|
|
|
|
to the pool ``vms`` and read-only access to the pool ``images``, run the
|
2022-12-06 14:20:24 +00:00
|
|
|
|
following command:
|
2017-07-07 14:41:07 +00:00
|
|
|
|
|
2022-12-06 14:20:24 +00:00
|
|
|
|
.. prompt:: bash $
|
2017-07-07 14:41:07 +00:00
|
|
|
|
|
2022-12-06 14:20:24 +00:00
|
|
|
|
ceph auth get-or-create client.qemu mon 'profile rbd' osd 'profile rbd pool=vms, profile rbd-read-only pool=images' mgr 'profile rbd pool=images'
|
|
|
|
|
|
|
|
|
|
The output from the ``ceph auth get-or-create`` command is the keyring for the
|
2022-12-07 14:43:31 +00:00
|
|
|
|
specified Ceph user ID, which can be written to
|
|
|
|
|
``/etc/ceph/ceph.client.{ID}.keyring``.
|
2022-12-06 14:20:24 +00:00
|
|
|
|
|
2022-12-07 14:43:31 +00:00
|
|
|
|
.. note:: Specify the Ceph user ID by providing the ``--id {id} argument when
|
|
|
|
|
using the ``rbd`` command. This argument is optional.
|
2017-07-07 14:41:07 +00:00
|
|
|
|
|
2012-05-31 22:35:33 +00:00
|
|
|
|
Creating a Block Device Image
|
2012-09-18 18:41:32 +00:00
|
|
|
|
=============================
|
|
|
|
|
|
2013-06-14 23:56:58 +00:00
|
|
|
|
Before you can add a block device to a node, you must create an image for it in
|
2022-12-08 23:53:14 +00:00
|
|
|
|
the :term:`Ceph Storage Cluster`. To create a block device image, run a command of this form:
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-08 23:53:14 +00:00
|
|
|
|
.. prompt:: bash $
|
|
|
|
|
|
|
|
|
|
rbd create --size {megabytes} {pool-name}/{image-name}
|
2017-07-07 14:41:07 +00:00
|
|
|
|
|
2015-01-21 08:47:41 +00:00
|
|
|
|
For example, to create a 1GB image named ``bar`` that stores information in a
|
2022-12-08 23:53:14 +00:00
|
|
|
|
pool named ``swimmingpool``, run this command:
|
|
|
|
|
|
|
|
|
|
.. prompt:: bash $
|
|
|
|
|
|
|
|
|
|
rbd create --size 1024 swimmingpool/bar
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-08 23:53:14 +00:00
|
|
|
|
If you don't specify a pool when you create an image, then the image will be
|
|
|
|
|
stored in the default pool ``rbd``. For example, if you ran this command, you
|
2022-12-27 12:28:49 +00:00
|
|
|
|
would create a 1GB image named ``foo`` that is stored in the default pool
|
2022-12-08 23:53:14 +00:00
|
|
|
|
``rbd``:
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-08 23:53:14 +00:00
|
|
|
|
.. prompt:: bash $
|
2015-01-21 08:47:41 +00:00
|
|
|
|
|
2022-12-08 23:53:14 +00:00
|
|
|
|
rbd create --size 1024 foo
|
2015-01-21 08:47:41 +00:00
|
|
|
|
|
2022-12-08 23:53:14 +00:00
|
|
|
|
.. note:: You must create a pool before you can specify it as a source. See
|
|
|
|
|
`Storage Pools`_ for details.
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
|
|
|
|
Listing Block Device Images
|
2012-09-18 18:41:32 +00:00
|
|
|
|
===========================
|
|
|
|
|
|
2022-12-09 00:21:47 +00:00
|
|
|
|
To list block devices in the ``rbd`` pool, run the following command:
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 00:21:47 +00:00
|
|
|
|
.. prompt:: bash $
|
|
|
|
|
|
|
|
|
|
rbd ls
|
|
|
|
|
|
|
|
|
|
.. note:: ``rbd`` is the default pool name, and ``rbd ls`` lists the commands
|
|
|
|
|
in the default pool.
|
|
|
|
|
|
|
|
|
|
To list block devices in a particular pool, run the following command, but
|
|
|
|
|
replace ``{poolname}`` with the name of the pool:
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 00:21:47 +00:00
|
|
|
|
.. prompt:: bash $
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 00:21:47 +00:00
|
|
|
|
rbd ls {poolname}
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 00:21:47 +00:00
|
|
|
|
For example:
|
|
|
|
|
|
|
|
|
|
.. prompt:: bash $
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 00:21:47 +00:00
|
|
|
|
rbd ls swimmingpool
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 00:21:47 +00:00
|
|
|
|
To list "deferred delete" block devices in the ``rbd`` pool, run the
|
|
|
|
|
following command:
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 00:21:47 +00:00
|
|
|
|
.. prompt:: bash $
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 00:21:47 +00:00
|
|
|
|
rbd trash ls
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 00:21:47 +00:00
|
|
|
|
To list "deferred delete" block devices in a particular pool, run the
|
|
|
|
|
following command, but replace ``{poolname}`` with the name of the pool:
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 00:21:47 +00:00
|
|
|
|
.. prompt:: bash $
|
|
|
|
|
|
|
|
|
|
rbd trash ls {poolname}
|
|
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
|
|
.. prompt:: bash $
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 00:21:47 +00:00
|
|
|
|
rbd trash ls swimmingpool
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2012-05-31 22:35:33 +00:00
|
|
|
|
Retrieving Image Information
|
2012-09-18 18:41:32 +00:00
|
|
|
|
============================
|
|
|
|
|
|
2022-12-09 00:25:55 +00:00
|
|
|
|
To retrieve information from a particular image, run the following command, but
|
2024-03-18 04:34:44 +00:00
|
|
|
|
replace ``{image-name}`` with the name of the image:
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 00:25:55 +00:00
|
|
|
|
.. prompt:: bash $
|
|
|
|
|
|
|
|
|
|
rbd info {image-name}
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 00:25:55 +00:00
|
|
|
|
For example:
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 00:25:55 +00:00
|
|
|
|
.. prompt:: bash $
|
|
|
|
|
|
|
|
|
|
rbd info foo
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 00:25:55 +00:00
|
|
|
|
To retrieve information from an image within a pool, run the following command,
|
|
|
|
|
but replace ``{image-name}`` with the name of the image and replace
|
|
|
|
|
``{pool-name}`` with the name of the pool:
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 00:25:55 +00:00
|
|
|
|
.. prompt:: bash $
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 00:25:55 +00:00
|
|
|
|
rbd info {pool-name}/{image-name}
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 00:25:55 +00:00
|
|
|
|
For example:
|
|
|
|
|
|
|
|
|
|
.. prompt:: bash $
|
|
|
|
|
|
|
|
|
|
rbd info swimmingpool/bar
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 00:25:55 +00:00
|
|
|
|
.. note:: Other naming conventions are possible, and might conflict with the
|
|
|
|
|
naming convention described here. For example, ``userid/<uuid>`` is a
|
|
|
|
|
possible name for an RBD image, and such a name might (at the least) be
|
2022-12-10 03:20:17 +00:00
|
|
|
|
confusing.
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
|
|
|
|
Resizing a Block Device Image
|
2012-09-18 18:41:32 +00:00
|
|
|
|
=============================
|
|
|
|
|
|
2013-06-14 23:56:58 +00:00
|
|
|
|
:term:`Ceph Block Device` images are thin provisioned. They don't actually use
|
2022-12-09 01:02:31 +00:00
|
|
|
|
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, run one
|
|
|
|
|
of the following commands:
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 01:02:31 +00:00
|
|
|
|
Increasing the Size of a Block Device Image
|
|
|
|
|
-------------------------------------------
|
|
|
|
|
|
|
|
|
|
.. prompt:: bash $
|
|
|
|
|
|
|
|
|
|
rbd resize --size 2048 foo
|
|
|
|
|
|
|
|
|
|
Decreasing the Size of a Block Device Image
|
|
|
|
|
-------------------------------------------
|
|
|
|
|
|
|
|
|
|
.. prompt:: bash $
|
|
|
|
|
|
|
|
|
|
rbd resize --size 2048 foo --allow-shrink
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Removing a Block Device Image
|
2012-09-18 18:41:32 +00:00
|
|
|
|
=============================
|
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
To remove a block device, run the following command, but replace
|
|
|
|
|
``{image-name}`` with the name of the image you want to remove:
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
.. prompt:: bash $
|
|
|
|
|
|
|
|
|
|
rbd rm {image-name}
|
|
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
|
|
.. prompt:: bash $
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
rbd rm foo
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
Removing a Block Device from a Pool
|
|
|
|
|
-----------------------------------
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
To remove a block device from a pool, run the following command but replace
|
|
|
|
|
``{image-name}`` with the name of the image to be removed, and replace
|
|
|
|
|
``{pool-name}`` with the name of the pool from which the image is to be
|
|
|
|
|
removed:
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
.. prompt:: bash $
|
|
|
|
|
|
|
|
|
|
rbd rm {pool-name}/{image-name}
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
For example:
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
.. prompt:: bash $
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
rbd rm swimmingpool/bar
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
"Defer Deleting" a Block Device from a Pool
|
|
|
|
|
-------------------------------------------
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
To defer delete a block device from a pool (which entails moving it to the
|
|
|
|
|
"trash" and deleting it later), run the following command but replace
|
|
|
|
|
``{image-name}`` with the name of the image to be moved to the trash and
|
|
|
|
|
replace ``{pool-name}`` with the name of the pool:
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
.. prompt:: bash $
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
rbd trash mv {pool-name}/{image-name}
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
For example:
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
.. prompt:: bash $
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
rbd trash mv swimmingpool/bar
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
Removing a Deferred Block Device from a Pool
|
|
|
|
|
--------------------------------------------
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
To remove a deferred block device from a pool, run the following command but
|
2024-03-18 04:02:39 +00:00
|
|
|
|
replace ``{image-id}`` with the ID of the image to be removed, and replace
|
2022-12-09 01:16:27 +00:00
|
|
|
|
``{pool-name}`` with the name of the pool from which the image is to be
|
|
|
|
|
removed:
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
.. prompt:: bash $
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2024-03-18 04:02:39 +00:00
|
|
|
|
rbd trash rm {pool-name}/{image-id}
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
For example:
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
.. prompt:: bash $
|
|
|
|
|
|
|
|
|
|
rbd trash rm swimmingpool/2bf4474b0dc51
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
* You can move an image to the trash even if it has snapshot(s) or is
|
|
|
|
|
actively in use by clones. However, you cannot remove it from the trash
|
|
|
|
|
under those conditions.
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:16:27 +00:00
|
|
|
|
* You can use ``--expires-at`` to set the deferment time (default is
|
|
|
|
|
``now``). If the deferment time has not yet arrived, you cannot remove the
|
|
|
|
|
image unless you use ``--force``.
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
|
|
|
|
Restoring a Block Device Image
|
2017-08-01 09:16:39 +00:00
|
|
|
|
==============================
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:31:07 +00:00
|
|
|
|
To restore a deferred delete block device in the rbd pool, run the
|
|
|
|
|
following command but replace ``{image-id}`` with the ID of the image:
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:31:07 +00:00
|
|
|
|
.. prompt:: bash $
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:31:07 +00:00
|
|
|
|
rbd trash restore {image-id}
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:31:07 +00:00
|
|
|
|
For example:
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:31:07 +00:00
|
|
|
|
.. prompt:: bash $
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:31:07 +00:00
|
|
|
|
rbd trash restore 2bf4474b0dc51
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:31:07 +00:00
|
|
|
|
Restoring a Block Device Image in a Specific Pool
|
|
|
|
|
-------------------------------------------------
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:31:07 +00:00
|
|
|
|
To restore a deferred delete block device in a particular pool, run the
|
|
|
|
|
following command but replace ``{image-id}`` with the ID of the image and
|
|
|
|
|
replace ``{pool-name}`` with the name of the pool:
|
|
|
|
|
|
|
|
|
|
.. prompt:: bash $
|
|
|
|
|
|
|
|
|
|
rbd trash restore {pool-name}/{image-id}
|
|
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
|
|
.. prompt:: bash $
|
|
|
|
|
|
|
|
|
|
rbd trash restore swimmingpool/2bf4474b0dc51
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Renaming an Image While Restoring It
|
|
|
|
|
------------------------------------
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2018-07-09 02:53:59 +00:00
|
|
|
|
You can also use ``--image`` to rename the image while restoring it.
|
|
|
|
|
|
2022-12-09 01:31:07 +00:00
|
|
|
|
For example:
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2022-12-09 01:31:07 +00:00
|
|
|
|
.. prompt:: bash $
|
|
|
|
|
|
|
|
|
|
rbd trash restore swimmingpool/2bf4474b0dc51 --image new-name
|
2017-07-22 07:09:25 +00:00
|
|
|
|
|
2012-05-31 22:35:33 +00:00
|
|
|
|
|
2017-06-26 13:48:00 +00:00
|
|
|
|
.. _create a pool: ../../rados/operations/pools/#create-a-pool
|
2012-12-03 20:22:37 +00:00
|
|
|
|
.. _Storage Pools: ../../rados/operations/pools
|
2013-01-28 18:13:56 +00:00
|
|
|
|
.. _RBD – Manage RADOS Block Device (RBD) Images: ../../man/8/rbd/
|
2017-07-07 14:41:07 +00:00
|
|
|
|
.. _create a Ceph user: ../../rados/operations/user-management#add-a-user
|