qcow2 notes

rhel-guest-image-7.2-20151102.0.x86_64.qcow2

available from access.redhat.com

image info

$ qemu-img info rhel-guest-image-7.2-20151102.0.x86_64.qcow2 
image: rhel-guest-image-7.2-20151102.0.x86_64.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 453M
cluster_size: 65536
Format specific information:
    compat: 0.10
    refcount bits: 16
$ virt-filesystems --long -h --all -a rhel-guest-image-7.2-20151102.0.x86_64.qcow2 
Name       Type        VFS  Label  MBR  Size  Parent
/dev/sda1  filesystem  xfs  -      -    6.0G  -
/dev/sda1  partition   -    -      83   6.0G  /dev/sda
/dev/sda   device      -    -      -    10G   -

resize the image

$ qemu-img create -f qcow2 rhel7.1-guest.qcow2 100G
Formatting 'rhel7.2-guest.qcow2', fmt=qcow2 size=107374182400 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16
$ virt-resize --expand /dev/sda1 rhel-guest-image-7.2-20151102.0.x86_64.qcow2 rhel7.2-guest.qcow2 
[   0.0] Examining rhel-guest-image-7.2-20151102.0.x86_64.qcow2
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ --:--
**********

Summary of changes:

/dev/sda1: This partition will be resized from 6.0G to 100.0G.  The 
filesystem xfs on /dev/sda1 will be expanded using the 'xfs_growfs' method.

**********
[   6.5] Setting up initial partition table on rhel7.2-guest.qcow2
[   6.6] Copying /dev/sda1
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
[  18.5] Expanding /dev/sda1 using the 'xfs_growfs' method

Resize operation completed with no errors.  Before deleting the old disk, 
carefully check that the resized disk boots and works correctly.
$ qemu-img info rhel7.2-guest.qcow2 
image: rhel7.2-guest.qcow2
file format: qcow2
virtual size: 100G (107374182400 bytes)
disk size: 1.1G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

modifying the new image before we boot it

$ virt-customize -a rhel7.2-guest.qcow2 --run-command 'yum remove cloud-init* -y'
[   0.0] Examining the guest ...
[  12.8] Setting a random seed
[  12.8] Running: yum remove cloud-init* -y
[  16.3] Finishing off
$ virt-customize -a rhel7.2-guest.qcow2 --root-password password:redhat
[   0.0] Examining the guest ...
[  11.8] Setting a random seed
[  11.8] Setting passwords
[  13.5] Finishing off
$ virt-customize -a rhel7.2-guest.qcow2 --hostname rhel7-host.localdomain
[   0.0] Examining the guest ...
[  14.9] Setting a random seed
[  14.9] Setting the hostname: rhel7-host.localdomain
[  15.0] Finishing off
virt-customize -a test.qcow2 --sm-register --sm-credentials USERNAME:password:PASSWORD --sm-attach pool:POOLID
[   0.0] Examining the guest ...
[  15.4] Setting a random seed
[  15.4] Registering with subscription-manager
[  25.0] Attaching to the pool ###########################
[  33.6] Finishing off
$ virt-customize -a test.qcow2 --update
[   0.0] Examining the guest ...
[  15.2] Setting a random seed
[  15.2] Updating core packages
[ 167.7] Finishing off
$ virt-customize -a test.qcow2 --timezone America/Los_Angeles
[   0.0] Examining the guest ...
[  15.7] Setting a random seed
[  15.7] Setting the timezone: America/Los_Angeles
[  16.1] Finishing off