Map the RBD image via rbd-nbd is very similar using the rbd kernel mapping. A simple “rbd nbd map” command helps you mapping the RBD image.
# rbd ls -p mirroring
image001
# rbd nbd map mirroring/image001
/dev/nbd0
# mkfs.xfs /dev/nbd0
# mount /dev/nbd0 /mnt
# df -h /mnt/
Filesystem Size Used Avail Use% Mounted on
/dev/nbd0 1.0T 33M 1.0T 1% /mnt
# umount /mnt
# rbd nbd unmap /dev/nbd0
We imitated the service rbdmap and created the nbdmap for mapping the rbd-nbd device automatically. The nbdmap service will map the list and mount it while booting. Once you map the rbd image and format it manually for the first time, you do not need to worry about mapping the images every time.
Step1: Format the RBD image
Refer to the first paragraph
Step2: Edit the nbdmap config
# cat /etc/ceph/nbdmap
#pool #image #mountpoint
mirroring image001 /mnt/rbdnbd
Step3: Copy the binary & systemd service config
# cp nbdmap.bin /usr/bin/nbdmap
# cp nbdmap.service /etc/systemd/system/nbdmap.service
Step4: Enable the nbdmap service
# systemctl enable nbdmap
# systemctl start nbdmap