Block Device Guide | Basic Ceph Administration

  • Hard drives
  • CD/DVD discs
  • Floppy disks
  • Traditional 9-track tapes

Prerequisites:

  • A running Ceph cluster.
  • Root-level access to the client node.

Basic Administration:

1. Creating a block device pool

[root@ceph-01 ~]# ceph osd pool create my-pool 128
pool 'my-pool' created
[root@ceph-01 ~]# ceph osd pool application enable my-pool rbd
[root@ceph-01 ~]# rbd pool init -p my-pool

2. Creating a block device image

[root@ceph-01 ~]# rbd create data --size 10G --pool my-pool
[root@ceph-01 ~]# rbd ls -l my-pool
NAME SIZE PARENT FMT PROT LOCK
data 10 GiB 2
[root@ceph-01 ~]# rbd --image data  -p my-pool info
rbd image 'data':
size 10 GiB in 2560 objects
order 22 (4 MiB objects)
snapshot_count: 0
id: 3963beb71cee
block_name_prefix: rbd_data.3963beb71cee
format: 2
features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
op_features:
flags:
create_timestamp: Sat Oct 23 08:09:01 2021
access_timestamp: Sat Oct 23 08:09:01 2021
modify_timestamp: Sat Oct 23 08:09:01 2021

3. Resizing a block device image

[root@ceph-01 ~]# rbd resize --image data -p my-pool --size 12G
Resizing image: 100% complete...done.
[root@ceph-01 ~]#
[root@ceph-01 ~]# rbd ls -l my-pool
NAME SIZE PARENT FMT PROT LOCK
data 12 GiB 2

4. Map and mount a Ceph Block Device on client host

[root@ceph-01 ~]# ssh ceph-client
Last login: Sat Oct 23 07:58:58 2021 from 192.168.1.231
[root@ceph-client ~]# dnf -y install centos-release-ceph-pacific epel-release
[root@ceph-client ~]# dnf -y install ceph-common
[root@ceph-client ~]# scp root@ceph-01:/etc/ceph/ceph.conf /etc/ceph/ceph.conf
ceph.conf 100% 277 39.4KB/s 00:00
[root@ceph-client ~]#
[root@ceph-client ~]# scp root@ceph-01:/etc/ceph/ceph.client.admin.keyring /etc/ceph/ceph.client.admin.keyring
ceph.client.admin.keyring 100% 151 21.7KB/s 00:00
[root@ceph-client ~]# rbd ls -p my-pool -l
NAME SIZE PARENT FMT PROT LOCK
data 12 GiB 2
[root@ceph-client ~]# rbd map -p my-pool data
/dev/rbd0
[root@ceph-client ~]# rbd showmapped
id pool namespace image snap device
0 my-pool data - /dev/rbd0
[root@ceph-client ~]# mkfs.xfs /dev/rbd0
meta-data=/dev/rbd0 isize=512 agcount=16, agsize=196608 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=3145728, imaxpct=25
= sunit=16 swidth=16 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=16 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
Discarding blocks...Done.
[root@ceph-client ~]# mount /dev/rbd0 /mnt
[root@ceph-client ~]# df -hT
[root@ceph-client ~]# curl https://cloud.centos.org/centos/8/x86_64/images/CentOS-8-GenericCloud-8.1.1911-20200113.3.x86_64.qcow2 -o /mnt/CentOS-8.qcow2
[root@ceph-client ~]#
[root@ceph-client ~]# df -hT /mnt
Filesystem Type Size Used Avail Use% Mounted on
/dev/rbd0 xfs 12G 802M 12G 7% /mnt
[root@ceph-client ~]# ls -lh /mnt
total 683M
-rw-r--r--. 1 root root 683M Oct 23 08:54 CentOS-8.qcow2

5. Removing a block device image

[root@ceph-client ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 40G 0 disk
├─sda1 8:1 0 600M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 38.4G 0 part
├─cl-root 253:0 0 34.4G 0 lvm /
└─cl-swap 253:1 0 4G 0 lvm [SWAP]
sr0 11:0 1 1024M 0 rom
rbd0 252:0 0 12G 0 disk /mnt
[root@ceph-client ~]# umount /mnt
[root@ceph-01 ~]# rbd device list
id pool namespace image snap device
0 my-pool data — /dev/rbd0
[root@ceph-01 ~]# rbd device unmap /dev/rbd/my-pool/data
[root@ceph-01 ~]# rbd -p my-pool ls
data
[root@ceph-01 ~]# rbd rm -p my-pool data
Removing image: 100% complete...done.

--

--

--

Cloud Consultant | RHCSA | RHCE in Red Hat OpenStack | Google Cloud ACE | AWS SAA | LinkedIn: https://www.linkedin.com/in/achchusnulchikam

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What is End-to-End (E2E) Testing? All You Need to Know

UX research for beginners

Coding & Capes: How Programming is a Real Super Power

Game Development Tutorial for Beginners #2

Getting Started with Git and Github

Monkey Madness: The Process

Understanding SaaS: Commonly Used SaaS Terminologies and Acronyms

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ach.Chusnul Chikam

Ach.Chusnul Chikam

Cloud Consultant | RHCSA | RHCE in Red Hat OpenStack | Google Cloud ACE | AWS SAA | LinkedIn: https://www.linkedin.com/in/achchusnulchikam

More from Medium

Python short-trick to load any local directory as python module in script

How to build and push docker image to container registry

Host Blazor on ECS Part 2 —Configure Load Balancer with SSL

ACM — request certificate

Launch a Container on Docker in GUI Mode