How Do I Quickly Create Multiple Block Devices?
In the following example, 30 block devices are created in the RBD storage pool vdbench, and the size of each block device is 200 GB.
- Create a script to create 30 block devices in the RBD storage pool. The size of each block device is 200 GB.
1vi create_image.shAdd the following content to the file:
1 2 3 4 5 6 7 8 9 10 11 12 13
#!/bin/bash pool="vdbench" size="204800" createimages() { for image in {1..30} do rbd create image${image} --size ${size} --pool ${pool} --image-format 2 --image-feature layering sleep 1 done } createimages
- Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
- Run the script.
1bash create_image.shrbd create image is used to configure images. In the command:- ${image} indicates the index of an image.
- --pool specifies the storage pool.
- --image-format specifies the image format. Format 1 has been deprecated, and format 2 supports cloning and will support more features.
- --image-feature specifies whether to enable the features of the specified --image-format.
- Common commands:
# List images in the vdbench storage pool. rbd ls --pool vdbench # Delete image2 from the vdbench storage pool. rbd rm vdbench/image2
For more information about RBD, see the description in the Ceph open source community.
Parent topic: FAQs