Programster's Blog

Tutorials focusing on Linux, programming, and open source

Ceph - Deploy and Mount a Block Device

This tutorial is going to demonstrate the provisioning and deployment of a block device on our ceph cluster. If you don't already have a Ceph cluster, please follow my previous tutorials on how to set one up.

Steps

Create a virtual machine to act as your client. If you already have a VM that you want to act as your client then skip this step.

Add the cluster's ceph user (and home directory) to the client, and give the ceph user permission to use sudo without a password. This was covered in stage 1 of the setup.

On the admin node, use the ceph-deploy tool from within the cluster folder, to install the ceph-client on the client VM you just created.

ceph-deploy install {client ip or hostname}

Now configure the client so that it can connect to the cluster.

ceph-deploy admin {client ip or hostname}

Creating the block device

On the client, and using any user (e.g. not necessarily the ceph user), let's create a basic block device that's not assigned to any pools.

rbd create {block-device-name} --size {size-in-megabytes}

e.g. To create a 1Gb block device

rbd create bar --size 1024

You should now be able to see the block device by listing them:

rbd ls

Load the rbd module

sudo modprobe rbd

Note: This block device could have been created, or listed on any of the other cluster nodes.

Map the image to a block device

sudo rbd map {image name} --name client.admin -m {monitor node ip or hostname}

Create a filesystem on the block device. I choese ext4 but you can choose something else.

sudo mkfs.ext4 -m0 /dev/rbd/rbd/{image name}

Mount the filesystem

sudo mkdir /mnt/{folder name}
sudo mount /dev/rbd/rbd/{image name} /mnt/{folder name}
cd /mnt/{folder name}

Now if you run something like df -h or pydf you should see the block device.

References