Created
February 9, 2017 01:44
-
-
Save Spenser309/2ec1358b03e2f7beaf07e77f3f680589 to your computer and use it in GitHub Desktop.
Example of how to resize and recompress a disk image for openstack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ openstack --os-identity-api-version=3 image save --file <filename> <image name> | |
$ virt-df -h -a <filename> # shows used/free disk space | |
$ guestfish -a <filename> <<EOF | |
run | |
list-filesystems # informational only | |
e2fsck-f /dev/sda1 | |
resize2fs-size /dev/sda1 <size>G | |
exit | |
EOF | |
$ qemu-img create -f qcow2 <filename>.qcow2 <size>.2G # Add 200MB as padding | |
$ virt-resize --resize /dev/sda1=<size>G --no-extra-partition <filename> <filename>.qcow2 | |
$ qemu-img convert -O qcow2 -c <filename>.qcow2 <filename>.qcow2c | |
$ virt-df -h -a <filename>.qcow2c # validate changes | |
$ openstack --os-identity-api-version=3 image create --disk-format=qcow2 --min-disk=<size+1>G --file <filename>.qcow2c <image name> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Have you found that using the -c option actually results in a much smaller disk? I've done some internal testing and found conversions move super fast without the -c flag, but the resulting file is definitely larger. What format is it being compressed in?