Mounting RBD at Boot Under CentOS 7

In Linux Tutorials

Mount RBD at Boot on CentOS7

This tutorial covers mounting an RBD image at boot under CentOS 7. Make sure to unmount the RBD you want to have mount at boot before following this tutorial. This tutorial requires a CentOS 7 client with a client or admin keyring from Ceph, and a working Ceph cluster. This tutorial also assumes you have already created the RBD image you want to be mounted at boot. Let’s begin!

Assumptions

This tutorial assumes the node you are implementing this on has connectivity to a working ceph cluster and also assumes that kernel module RBD is enabled.

For the purposes of this tutorial I will place variables, the values specified here:

$poolname = your_pools_name

$rbdimage = the_name_of_your_rbd_image

$mountpoint = place_to_mount_the rbd

Create A systemd service to map and mount automatically on boot / demand

You will want to automatically load the kernel module, map the appropriate rbd storage to a local device and mount the ceph image.

Here is a simple script for mounting and un-mounting RBD images create one at /usr/bin/mount-rbd-$poolname-$rbdimage for each of your RBD images:

Create a new systemd service unit (/etc/systemd/system/mount-rbd-$poolname-$rbdimage.service) for each of your remote rbd images:

 

Make sure your target RBD is unmounted. Start the service and check whether /dev/rbd0 is created or not:

Mounting an RBD at Boot Under CentOS 7 is Easy!

If everything seems to be fine, enable the service to start on boot:

You now have a working RBD mount at boot time! I wil be following this up with a complete tutorial on the entire process of creating an RBD at some point in the future. Leave your thoughts in the comments below.

Submit a comment