Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleConvert images
$ qemu-img convert -f qcow2 -O raw debian-8.2.0-openstack-amd64.qcow2 debian-8.2.0-openstack-amd64.raw

Anchor
upload
upload

Uploading new images

To upload a new image to glance, the following command can be useful:

Code Block
titleUpload image to glance
glanceopenstack image-create --name <image_name> create --file <image_location> --disk-format raw --container-format bare [--public|--private] <image_name>
# There is-public True --progress  a bug where in some/most/many circumstances you will not be able to use --protected with the "image create" command. Workaround: Just set the protected flag after the image has been uploaded
openstack image set --protected <image_name>

For example, the following command would upload an ubuntu image:

Code Block
titleUpload image to glance
glanceopenstack image- create --name "Ubuntu Server 16.04 (Xenial) amd64" --file xenial-server-cloudimg-amd64-disk1.img.raw --disk-format raw --container-format bare --is-public True --progresspublic "Ubuntu Server 16.04 (Xenial) amd64"
openstack image set --protected "Ubuntu Server 16.04 (Xenial) amd64"

The "–publicThe "–is-public Trueflag is used to indicate that all tenants projects should have access to this image, and the upload would then require admin credentials. In the case of an image upload which should only be accessible to the tenant project uploading it, that flag can be omitted.

Manipulate image-init images

Required packages for ubuntu, other OS might have different names. The procedure is tested with raw and qcow2 images.

  • qemu-utils
  • guestfish
  • libguestfs-tools
  • working sudo for your user

Verify that the cloud-init image is ok.

Code Block
titleqemu
:~$  qemu-img check <image name>
No errors were found on the image.
14510/36032 = 40.27% allocated, 98.23% fragmented, 98.04% compressed clusters
Image end offset: 289210368

Manipulate the image with guestfish

Code Block
titleguestfish
# Mounting the filesystem
:~$ sudo guestfish

Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell

><fs> add <path to image>
><fs> run
><fs> list-filesystems 
/dev/sda1: ext4
><fs> mount /dev/sda1 /

# Editing a file
><fs> vi /etc/fstab

#Copying in a file from outside the image
><fs> copy-in <file outside the image> <pat to where to put it inside image>

# Commiting and exiting guestfish. Exit does both
><fs> exit


Change existing images