Map/unmap RBD device on boot/shutdown
Quick how-to on mapping/unmapping a RBD device during startup and shutdown.
We are going to use an init script provided by the
During the boot sequence, the init script first looks at
/etc/rbdmap and will map devices accordingly.
Then, it will trigger
As soon as the system is halted or rebooted, the script will unmount and unmap the devices.
Since you are not going to map/unmap RBD devices from one of your Ceph node you have to download the init script and install it on the client machine.
Download the init script and add it to the boot sequence:
$ sudo wget https://raw.github.com/ceph/ceph/a4ddf704868832e119d7949e96fe35ab1920f06a/src/init-rbdmap -O /etc/init.d/rbdmap
Create the device:
$ sudo rbd -p leseb create boot --size 10240
Assuming the pool
leseb is readable and writable by a user
leseb who has the corresponding key.
# RbdDevice Parameters leseb/boot id=leseb,keyring=/etc/ceph/ceph.client.leseb.keyring
Format your device:
$ sudo mkfs.xfs /dev/rbd/leseb/boot
Then edit your fstab with:
/dev/rbd/leseb/boot /mnt/ xfs defaults,_netdev 0 0
$ sudo /etc/init.d/rbdmap start
$ sudo rbd showmapped
Obviously you definitely want to reboot your system to try it out :)