Planet Ceph

Aggregated news from external sources

December 19, 2013

Real size of a Ceph RBD image

RBD images are thin-provisionned thus you don’t always know the real size of the image.
Moreover, Ceph doesn’t provide any simple facility to check the real size of an image.
This blog post took his inspiration from the Ceph mailing list.

Create an image:

1
$ rbd create -s 1024 toto

The magic formula using block differential:

1
2
$ rbd diff rbd/tota | awk '{ SUM += $2 } END { print SUM/1024/1024 " MB" }'
0 MB

Further testing:

1
2
3
4
5
6
7
8
9
10
$ rbd map toto

$ rbd showmapped
id pool image snap device
2  rbd  toto  -    /dev/rbd1

$ dd if=/dev/zero of=/dev/rbd1 bs=1M count=10 oflag=direct
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 6.91826 s, 1.5 MB/s

So we wrote 10M, we should get 10MB in the ouput :).

1
2
$ rbd diff rbd/toto | awk '{ SUM += $2 } END { print SUM/1024/1024 " MB" }'
10 MB

Thanks to Olivier Bonvalet for the AWK command.

Careers