Ask Your Question

How to resize a snapshot with Openstack [closed]

asked 2013-06-10 09:05:31 -0500

Ph4nToM gravatar image

updated 2013-06-12 04:04:17 -0500

Hello! I create this post, because I tried to make a Snapshot of an instance with Openstack, but the size of this instance is the same than my initial image and it's so big!

image description

I tried the same experience in parralel with qemu. I converted my ISO image to an QCOW2 image, then I took a snapshot and I obtained a smaller image size.

image description

How can I do with Openstack to obtain this same result with my ISO image on Openstack?

Maybe any ideas?

edit retag flag offensive reopen merge delete

Closed for the following reason too localized by Ph4nToM
close date 2013-06-13 03:53:55.451536



Why are you closing your own questions?

mark0978 gravatar imagemark0978 ( 2013-06-26 19:10:19 -0500 )edit

Maybe It's because it's solved...

Ph4nToM gravatar imagePh4nToM ( 2013-06-28 07:59:33 -0500 )edit

That's now how it is this kind of system is designed to be used. Closed for "too localized" means the question is a poor question. The checkmark next to the accepted answer is how people know it is solved. Don't close questions just because they are answered.

mark0978 gravatar imagemark0978 ( 2013-06-28 17:04:36 -0500 )edit

Don't always accept the first answer, accept the best answer, and don't close them, especially when the reason doesn't make sense.

mark0978 gravatar imagemark0978 ( 2013-06-28 17:05:06 -0500 )edit

3 answers

Sort by ยป oldest newest most voted

answered 2013-06-11 09:00:00 -0500

jpichon gravatar image

This is just the way those different formats work. qcow optimises storage by using a copy-on-write mechanism. You should convert your images to this format if it works better for your use case.

edit flag offensive delete link more



Thank for your help, Yes It's amazing that we can't realize the same procedure with an ISO image without obtain a big size of image snapshoted... and if I use a qcow2 image, I've not the problem.. Why? I don't know

Ph4nToM gravatar imagePh4nToM ( 2013-06-12 03:55:15 -0500 )edit

This is the way they work. The QCOW format stores the delta of the changes when copying. The ISO format is a sector-by-sector uncompressed copy of the data, and a copy of that would be the same (i.e. ISO doesn't have the ability of only storing a delta of the changes.)

jpichon gravatar imagejpichon ( 2013-06-12 04:34:13 -0500 )edit

Actually it looks like qcow deltas can be used with raw images, but I don't see any option to choose the image format when creating a snapshot so I doubt it's possible in this use case...

jpichon gravatar imagejpichon ( 2013-06-12 04:49:40 -0500 )edit

answered 2013-06-11 11:08:44 -0500

smkr gravatar image

To shrink a qcow2 image fire up an instance off your snapshot and for each filesystem do:

   dd if=/dev/zero of=fillmeup
   rm fillmeup

f.e. if you've got '/' only:

   cd /
   dd if=/dev/zero of=fillmeup
   rm -f fillmeup

The same goes for /var, /usr etc.

I've crafter a script for my own usage:

   for q in \
      $(lsblk -ln \
        | grep "^vg_system" \
        | fgrep -v "[SWAP]" \
        | awk '{print $NF}') ; \
   do \
      pushd ${q} ; \
      dd if=/dev/zero of=fillme ; \
      sync ; \
      rm -f fillme ; \
      sync ; \
      popd ; \

From my experience, /dev/zero trick will give you an image about 20 times smaller.

PS. You may be able to avoid booting an instance off the snapshot by using 'guestmount' to mount the snapshot on the hypervisor (tip: use 'virt-df' to display a list of filesystems so you know what you'll be mounting). I haven't tried it (yet) so please reply with your results should you go this route.

edit flag offensive delete link more


Yes, I will test that in few times. Thanks for our help, I think it could work

Ph4nToM gravatar imagePh4nToM ( 2013-06-12 04:03:45 -0500 )edit

answered 2013-06-12 06:28:37 -0500

Ph4nToM gravatar image

Thanks for all your answer ;)

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2013-06-10 09:05:31 -0500

Seen: 2,560 times

Last updated: Jun 12 '13