Rate This Document
Findability
Accuracy
Completeness
Readability

How Do I Quickly Map Block Devices?

Use a script to quickly create 30 images (each 200 GB) based on Creating Block Devices.

  1. Create a script. Perform operations in this section on ceph1. The script will log in to client1, client2, and client3 to map the 30 images to the three clients (10 for each client) as local block devices.
    1
    vi map_image.sh
    

    Add the following content to the file:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    #!/bin/bash
    pool="vdbench"
    
    mapimages()
    {
    for i in {1..10}
    do
    ssh client1 "rbd map ${pool}/image${i}"
    done
    
    for i in {11..20}
    do
    ssh client2 "rbd map ${pool}/image${i}"
    done
    
    for i in {21..30}
    do
    ssh client3 "rbd map ${pool}/image${i}"
    done
    
    }
    mapimages
    
  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 map_image.sh
    
  • Common command:
    # On a client, cancel the mapping of image2 in the vdbench storage pool.
    rbd unmap vdbench/image1

For more information about RBD, see the description in the Ceph open source community.