Ask Your Question

how to: create a small linux image for openstack? [closed]

asked 2014-03-15 07:25:54 -0500

senyapsudah gravatar image

Hi guys,

I'm trying to find a way or guide on how can we setup or prepare a qcow2 image which only less then 1gb. As we can see most of the ready cloud image is only less then 500mb. When i try to prepare image less then 1gb i always hit error saying memory or hdisk is not enough.

From my understanding, this should be able achieved. Hope you guys can share.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by mpetason
close date 2014-06-09 10:12:03.402452

2 answers

Sort by ยป oldest newest most voted

answered 2014-03-15 09:31:10 -0500

mpetason gravatar image

You can accomplish this by setting up the partition table to only have a / partition. That means you won't setup swap/home or anything else. You would then do an install of a very base OS, usually minimal. Then you would install only the packages that you need. I've been able to get at or very close to 1g, but that is due to me needing to have specific packages and pre-populated config files.

You could take the minimal install and then modify packages so that you create an even smaller footprint. Then you would want to setup cloud-init to install the packages that users would expect on a base install. That way when the server comes up it installs stuff like ntp, traceroute, or other services/tools people are used to.

It depends on your use case. If your users are good at keeping their instances up to date then you could go with the cloud-init route, but if they are terrible at it and they need all of the packages to be the exact same without security updates/new versions, then you'll want to make smaller base images with the packages installed to begin with. That way for every instance they launch they have the same package versions, at least until they yum update/apt-get update.

edit flag offensive delete link more

answered 2014-05-09 05:37:17 -0500

senyapsudah gravatar image

found the solutions. the first thing need to do is to use below command:

virt-sparsify <input image> <output image>
qemu-img convert -c <input image> -O qcow2 <output image>

you should be able to get a compress image and the size can be around 200Mb+ depends on how you prepare the image in the first place. :)

edit flag offensive delete link more


In virt-sparsify 1.26, you could also use virt-sparsify --in-place option to do the sparsification in place (this is also much faster). Also if you use virt-sparsify in default (copying) mode, then it can do the format conversion (see --convert option in the man page).

rwmjones gravatar imagerwmjones ( 2014-05-09 05:44:47 -0500 )edit

Get to know Ask OpenStack

Resources for moderators

Question Tools



Asked: 2014-03-15 07:25:54 -0500

Seen: 742 times

Last updated: May 09 '14