What ephemeral disks are getting created for cloud instance ?

Whenever we are launching a cloud instance from an image some ephemeral disks are getting created corresponding to that instance. In this article, I am going to show the same disks and the nature of those disks.

Setup Details : All-in-one RHEL OSP 7  setup.

Step 1 : Let’s first check the default settings present in /etc/nova/nova.conf file which impacts the nature of these disks.

# VM image preallocation mode: “none” => no storage
# provisioning is done up front, “space” => storage is fully
# allocated at instance start (string value)
#preallocate_images=none

# Whether to use cow images (boolean value)
#use_cow_images=true

# Force backing images to raw format (boolean value)
#force_raw_images=true
force_raw_images=True

Step 2 : Let’s create a test instance using cirros image to see the disks created corresponding to an instance.

a) I am having two images in my glance store, one of them is a cirros image.

[root@allinone ~(keystone_admin)]# cd /var/lib/glance/images/

[root@allinone images(keystone_admin)]# ls -lsh
total 13M
13M -rw-r—– 1 glance glance  13M Dec 26 22:09 57e1491a-27ed-4cc2-a760-7053dc08dc99
208K -rw-r—– 1 glance glance 205K Dec 26 21:57 f66f084f-47c3-4120-b0d9-2871e36e48d0

b) Cirros image by default is of type qcow2.

[root@allinone images(keystone_admin)]# qemu-img info 57e1491a-27ed-4cc2-a760-7053dc08dc99
image: 57e1491a-27ed-4cc2-a760-7053dc08dc99
file format: qcow2
virtual size: 39M (41126400 bytes)
disk size: 13M
cluster_size: 65536
Format specific information:
compat: 0.10
refcount bits: 16

Step 3 : Let’s go to the instance directory and issue the tree command to see the contents. As no instance is running in cloud environment hence it’s showing empty.

[root@allinone instances(keystone_admin)]# pwd
/var/lib/nova/instances

[root@allinone instances(keystone_admin)]# tree
.

0 directories, 0 files

****Scenario 1 :

Just reiterating that we are using default options only.

Default settings :

egrep “qcow|raw|block” /etc/nova/nova.conf | egrep -v “^(#|$)”
force_raw_images=True

I have launched an instance using m1.tiny flavor of 1 GB.

a) Once my instance launced successfully, I  can see the below list of files and directories appeared under path /var/lib/nova/instances

[root@allinone instances(keystone_admin)]# tree
.
├── 019442fa-703d-4c96-b3bc-73a3fe3fb2f8
│   ├── console.log
│   ├── disk
│   ├── disk.info
│   └── libvirt.xml
├── _base
│   └── 84d1ce004776e837b60777b4ddf042eadfbf7020
└── locks
└── nova-84d1ce004776e837b60777b4ddf042eadfbf7020

3 directories, 6 files

b) In above tree output _base directory contains the actual cirros image which is copied from glance store. Note : In glance storage image was having qcow2 format, let’s check the format of image here :

[root@allinone _base(keystone_admin)]# ls -lsh
total 18M
18M -rw-r–r– 1 qemu qemu 40M Dec 27 00:49 84d1ce004776e837b60777b4ddf042eadfbf7020

We can see that image format has changed to “raw” from “qcow2”.

[root@allinone _base(keystone_admin)]# qemu-img info 84d1ce004776e837b60777b4ddf042eadfbf7020
image: 84d1ce004776e837b60777b4ddf042eadfbf7020
file format: raw
virtual size: 39M (41126400 bytes)
disk size: 17M

c) Disk which is created in 019442fa-703d-4c96-b3bc-73a3fe3fb2f8 directory is actually using raw image present in _base directory as backing file.

[root@allinone locks(keystone_admin)]# cd ../019442fa-703d-4c96-b3bc-73a3fe3fb2f8/

Notice  the “backing file” in below output. Disk “Virtual size” is equal to the (m1.tiny) flavor disk size i.e 1GB.

[root@allinone 019442fa-703d-4c96-b3bc-73a3fe3fb2f8(keystone_admin)]# qemu-img info disk
image: disk
file format: qcow2
virtual size: 1.0G (1073741824 bytes)
disk size: 1.4M
cluster_size: 65536
backing file: /var/lib/nova/instances/_base/84d1ce004776e837b60777b4ddf042eadfbf7020
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false

d) Just to verify that we are targeting on right disk.

[root@allinone 019442fa-703d-4c96-b3bc-73a3fe3fb2f8(keystone_admin)]# virsh list
Id    Name                           State
—————————————————-
2     instance-00000001              running

[root@allinone 019442fa-703d-4c96-b3bc-73a3fe3fb2f8(keystone_admin)]# virsh domblklist 2
Target     Source
————————————————
vda        /var/lib/nova/instances/019442fa-703d-4c96-b3bc-73a3fe3fb2f8/disk

e) I have changed the flavor from m1.tiny to m1.small. I can see the increased disk size from 1 GB to 20 GB. Note : This is a sparse disk.

[root@allinone instances(keystone_admin)]# qemu-img info 019442fa-703d-4c96-b3bc-73a3fe3fb2f8/disk
image: 019442fa-703d-4c96-b3bc-73a3fe3fb2f8/disk
file format: qcow2
virtual size: 20G (21474836480 bytes)
disk size: 19M
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false

****Scenario 2 :

a) I am changing one default option “preallocate_images” from none to space. Let’s see the difference made by this change to the instance disk.

If I am launching new instance now it’s reserving the whole space at boot time.

Here we can see that “disk size” and “virt size” both are same because of non-sparse nature which leads to better performance.

[root@allinone instances(keystone_admin)]# qemu-img info eb24bbab-4606-463b-bcc1-69c8cac15f70/disk
image: eb24bbab-4606-463b-bcc1-69c8cac15f70/disk
file format: qcow2
virtual size: 1.0G (1073741824 bytes)
disk size: 1.0G
cluster_size: 65536
backing file: /var/lib/nova/instances/_base/84d1ce004776e837b60777b4ddf042eadfbf7020
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s