SUSE Cloud/Images

From MicroFocusInternationalWiki
Revision as of 14:04, 19 September 2019 by Bmwiedemann (Talk | contribs) (document zerofree)

Jump to: navigation, search

Creation of images that are suitable for use in SUSE OpenStack Cloud is covered in great detail in

The short SUSE-specific version is: make sure, the cloud-init rpm is installed and its 4 .service files are enabled with

for s in init init-local config final ; do
    chkconfig cloud-$s on

This should ensure that

  • no default root-password is set (because otherwise evil password-bruteforcing-scripts will take over your machine within days).
  • the user's ssh public key gets pulled into the instance
  • it will resize your rootfs on first boot to the disk size available for the instance, allowing for the image to be below 1GB size to fit into the smallest default flavours.

When exporting existing snapshots of cloud VMs as images, they are often large (20 or 40 GB). You might want to use the 'zerofree' tool with ext2/3/4 partitions to fill unused disk-space with 0, to improve compressibility. Like this:

modprobe nbd
qemu-nbd -c /dev/nbd0 inputdiskimage
kpartx -av /dev/nbd0
fdisk -l /dev/nbd0
zerofree /dev/nbd0p2
kpartx -dv /dev/nbd0
qemu-nbd -d /dev/nbd0
qemu-img convert -c -O qcow2 inputdiskimage outputimage.qcow2

to create a compressed file in qcow2 format.