Planet Ceph

Aggregated news from external sources

October 17, 2017

Making RBD images persistent

Making RBD images persistent

Here’s a quick tutorial on how to make RBD’s, disable their features, and make them persistent at startup.

Creating the RBD image

Note – You really should go into your cepf.conf file and set rbd_default_features = 1 under the [global] section before going any further. Failure to do so will result in you images not wanting to map. If needed these features can be enabled later with red feature enable

In order to create the RBD image simply run the following command

1
rbd create pool_name/image_name --size 100GB

Mapping the RBD image

On the machine you wish to map this image run

1
2
3
4
rbd map pool_name/image_name
# Or if you have Cephx enabled you can use
rbd map pool_name/image_name --id admin --keyfile /secretfile.txt

This will map the image (if it is your first) to /dev/rbd0. It will also be mapped to /dev/rbd/pool_name/image_name. From here we can treat this as a normal block device and map it.

1
2
mkfs.xfs /dev/rbd/pool_name/image_name
mount /dev/rbd/pool_name/image_name /mnt/

Making this a persistent mount

To make this mountable upon boot, we need to edit our rbdmap file.

1
vi /etc/ceph/rbdmap
1
2
3
4
# RbdDevice Parameters
#poolname/imagename id=client,keyring=/etc/ceph/ceph.client.keyring
pool_name/image_name id=admin,keyring=/etc/ceph/ceph.client.admin.keyring

Create an /etc/fstab entry.

1
/dev/rbd/pool_name/image_name /mnt/target_dir xfs noauto 0 0

And last but not least enable the rbdmap service.

1
systemctl enable rbdmap

I hope this ends up helping someone, thank you for reading!

Source: Stephen McElroy (Making RBD images persistent)

Careers