Ask Your Question
0

Image in OpenStack is a shared and common file which binds to all instances or each VM have a copy of that in it's disk?

asked 2017-01-20 14:55:55 -0600

p.bagherpour gravatar image

updated 2017-01-20 14:59:08 -0600

Hi All

My question is about Image processes that happen when we select Launch machine, I create and upload my base image (ex. CentOS), and want to create an instance from that, Compute node get user request , nova-compute have cached image or ask from glance about image location, get the url of my image, then what happen? It copy base image for new instances? Or because OS in all VMs is repetitious, for saving disk space and …, use base image for number of instance and bind launched machines to it, save next changes to a new files in instances, so all new instances are combination of a point to base image and files (anything except of OS) which have the changes. As I learned any VM have .img file consist of OS, data (pics, files, application installed and ...) It means that compute node copy base image to new ephemeral space, boot machine from it and extend it by new change? So base image is only for copy from it and not bind to new instances. Is it correct?

I learned Compute Cache image which received from Glance, Actually I wanted to know more about after caching image in compute node, when launching VM, what happen! 1- Compute node give a copy of image to each new machine, and create .img for them? OR 2- all new machine use one shared base image, so in each VM disk only have just changes with a point to base image? For example I have one image CentOS that as last request cached to compute node, now a user requests 3 new centos VMs, 1-compute node copy 3 times from cached image and give them to new 3 VMs? OR 2- we have one cached common shared image between all 3 VMs? Naturally, if the answer is 2, we save disk space but I should be concerned about losing that shared image and I/O ps. 1 or 2 is correct?

I think we can check the size of new launched VMs, if it is equal or bigger than base image, it shows it have a copy of image in its disk. But unfortunately I do not have access to a VM launched.

Thanks in advance for any help

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2017-01-20 18:19:32 -0600

When a compute node runs several instances from the same image, indeed the image is shared. You can easily confirm this. Log on to that compute node as root and then:

# cd /var/lib/nova/instances
# qemu-img info INSTANCE-ID-1/disk
image: 9516726f-1ca8-4fdf-996b-94609b3e9df1/disk
file format: qcow2
virtual size: 40G (42949672960 bytes)
disk size: 17M
cluster_size: 65536
backing file: //var/lib/nova/instances/_base/74b1b76ab284b9e72f989bc12cb4f3eb2941ee36
(...)
# qemu-img info INSTANCE-ID-2/disk
image: dad886d1-ef8c-4170-abd5-cf618ea4f60e/disk
file format: qcow2
virtual size: 40G (42949672960 bytes)
disk size: 19M
cluster_size: 65536
backing file: //var/lib/nova/instances/_base/74b1b76ab284b9e72f989bc12cb4f3eb2941ee36
(...)

The two disks in the example share the same backing file.

So, what are those base images? They are raw images as far as Qemu is concerned, and sparse files as far as Linux is concerned.

# ls -lsh _base
total 1.9G
 18M -rw-r--r-- 1 libvirt-qemu libvirt-qemu  40M Jan 20 11:47 03985c69c(...)
954M -rw-r--r-- 1 libvirt-qemu libvirt-qemu 8.0G Jan 21 00:05 74b1b76a(...)
954M -rw-r--r-- 1 libvirt-qemu libvirt-qemu 8.0G Jan 20 04:44 e6ca599b(...)

# for i in _base/*
> do qemu-img info $i
> done
image: _base/03985c69c83c77a16e98b4acd9b2134f524d94fb
file format: raw
virtual size: 39M (41126400 bytes)
disk size: 18M
image: _base/74b1b76ab284b9e72f989bc12cb4f3eb2941ee36
file format: raw
virtual size: 8.0G (8589934592 bytes)
disk size: 953M
image: _base/e6ca599b76baf4a5b193b55c7933cb53ff051f39
file format: raw
virtual size: 8.0G (8589934592 bytes)
disk size: 953M

Disclaimers

  • This is on Mitaka, using libvirt/KVM as hypervisor. Don't expect implementation to be identical in other versions of OpenStack and other hypervisors.
  • This is a default configuration. There are a few config parameters that modify the behavior, such as force_raw_images, use_cow_images
  • Libvirt can be configured to use LVM volumes for ephemeral disks.
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2017-01-20 14:55:55 -0600

Seen: 620 times

Last updated: Jan 20 '17