What steps should I follow to reduce the size of an image

asked 2015-08-28 09:59:22 -0500

I have a rhel6 linux image of 50GB. The actual OS takes up only 3G so I want to reduce the amount of space it takes up.

I tried this method which fails to yield a bootable image.
1. launch ubuntu
2. attach a 100GB volume
3. glance image-down load the rhel6 image to the attached volume
4. qemu-img convert the rhel6 image to raw
5. attach another 100GB volume
6. dd the raw file to the newly attached volume
7. reboot the ubuntu server
8. run e2fsck on the newly created slice
9. resize2fs newslice 3G
10. fdisk new-slice
   a. delete old partition table
   b. add partition 1, make it 3G
   c. set bootable flag
   d. write table
11. mount newslice
12. discover that all the files are there
13. umount newslice
14. dd if=newvolume of=newimage.raw bs=512
15. qemu-img convert newimage.raw newimage.qcow2
16. glance image-create --name newimage --file newimage.qcow2 --disk qcow2 --container bare

when I try to nova boot newimage I get thiserror:

mount: wrong fs type, bad option, bad superblock on /dev/vda1
[ 2.7...] dracut Warning: Boot has failed

edit retag flag offensive close merge delete


You should not reduce the size, instead create a new image.

Tobias Urdin gravatar imageTobias Urdin ( 2015-08-31 09:00:45 -0500 )edit

Please illustrate how I can take this image which has everything I need but 46GB of space I don't want and create a new image from it that takes up just 4G?

tbodine gravatar imagetbodine ( 2015-08-31 09:18:16 -0500 )edit