Using virt-install to create a virtual machine template for OpenStack
Playing with KVM and OpenStack I wanted to create a custom Linux virtual machine template. The easiest way to do this is to first create a blank disk using the qemu-img command.
qemu-img create -f qcow2 /path/to/systemname.qcow2 20G
Here we specify the format as qcow2 with the -f switch, the path to where we want to create it, and the size by specifying 20G.
See the man page for qemu-img here
Once you have the disk created, you can then use the virt-install command to install an OS to the blank disk.
With the following command, we specify the amount of memory, hardware acceleration, name, path to the blank disk, what ISO file we want attached and console arguments so I can do the install via SSH session.
virt-install -r 2048 --accelerate -n systemname --disk path=/storage/vms/systemname.qcow2,format=qcow2,bus=virtio,cache=none --location /isos/CentOS_6.3_Install_DVD.iso --extra-args='console=tty0 console=ttyS0,115200n8 serial'
Without using the console specifications, you will not be able to fully boot the image, as it will hang at:
probing edd edd=off to disable ?
Not giving you much information as to what is going on :)
Once your image build is completed, you can then import the image into OpenStack using glance
glance image-create --name=systemname --is-public=true --container-format=bare --disk-format=qcow2 < /storage/vms/systemname.qcow2
You should be able to now see the image registered with Nova using the nova image list command.
Now you can use the nova boot command to create a VM from the image and start it.
nova boot --image systemname --flavor m1.small --key_name test my-first-server
Latest posts by Eric Sarakaitis (see all)
- Using PowerShell to Install SNMP and configure Community, Location and Contact on Windows 2008 - February 12, 2015
- RHEV 3.4 reports application show as not installed – Fixed - January 20, 2015
- Using vSAN RVC to learn more about your vSAN environment - January 9, 2015