Rate This Document
Findability
Accuracy
Completeness
Readability

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.

  1. Create a script to create 30 block devices in the RBD storage pool. The size of each block device is 200 GB.
    1
    vi create_image.sh
    

    Add 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
    
  2. Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
  3. Run the script.
    1
    bash create_image.sh
    
    rbd 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.