Short question: Do you know a fast and simple way for building headless Ubuntu 16.04 VM's (with a ssh server already installed and running) on a headless Ubuntu 16.04 Server?

Detailed version: So I really liked the ubuntu-vm-builder in 14.04. Yesterday I did set up a fresh 16.04 VM host PC and noticed that said builder can only create vm's until 14.04. (This answer to the question Creating Virtual Machines using ubuntu-vm-builder states out that Canonical abandoned/deprecated it (for which I have not found an official statement).

Extracting templates from packages: 100%
2016-06-28 17:02:43,136 INFO : W: --force-yes is deprecated, use one of the options starting with --allow instead.)

So I started experimenting with virt-builder and ran into this issue, which seems to be a fault of the VM host system.

Finally I tried to use virt-install directly, but it seems to me, that it is only possible to use vnc (not simply an ssh terminal) for the first connection. I followed this guide and got the VM running. But on the point where the ssh tunneling for the vnc connection is set up, I am struggling. I assume that you have to run this code on the VM host:

$ sudo virsh dumpxml gitMachine | grep vnc
$ <graphics type='vnc' port='5900' autoport='yes' listen=''>
$ ssh ubuntuDesktopUser@ubuntuDesktop -L 5900:

Above tunnel connected successfully (I got asked for certificate & password). But I was not able to connect to the VM from the Ubuntu Desktop with a VNC client as described in the guide.

Are there other tools out there which deliver the same results as ubuntu-vm-builder in 16.04?


Ok. This is what I came up with:

sudo virt-install \
--name test \
--ram 4096 \
--disk path=/home/myuser/kvm/vm_images/test.img,size=20 \
--vcpus 2 \
--os-type linux \
--os-variant ubuntu16.04 \
--network bridge=br0 \
--graphics none \
--console pty,target_type=serial \
--location http://debian.ethz.ch/ubuntu/ubuntu/dists/xenial/main/installer-amd64/ \
--extra-args 'hostname=test ip= dns= gateway= netmask= console=ttyS0,115200n8 serial' \

For most examples I found, the address of the --location parameter was down. This is what mine looks like:

Reachable as debian.ethz.ch, ubuntu.ethz.ch and ftp.ch.debian.org.
[ICO]   Name    Last modified   Size    Description
[PARENTDIR] Parent Directory        -    
[DIR]   20101020ubuntu448/  2016-04-16 23:53    -   Ubuntu APT repository
[DIR]   20101020ubuntu450/  2016-04-19 20:58    -   Ubuntu APT repository
[DIR]   20101020ubuntu451/  2016-04-20 17:53    -   Ubuntu APT repository
[DIR]   current/    2016-04-20 17:53    -    

After this command you land directly in the console of the gestOS, with the installer running. I'm not sure why it asks for the mirror to download during the installation, since there is specified the location parameter.

Not all the extra-args work for me. hostname and console are ok.

Since i have configured br0 on the host to have a static IP, the newly created VM is not able to resolve hosts in the internet. Therefor during the mirror choosing process in the installer of the guestOS fails. I was able to solve this issue by exiting to the shell of the installer:

nano /etc/resolv.conf
# changed content of the file to: hostname
# ping yahoo.com should work for example

afterwards you land back on the installer and can continue. Do not forget to check the OpenSSH server package during the installation. You can reach the VM afterwards by it's DHCP lease with putty. After the setup has finished, the VM will restart and the serial console session inside the hostOS will not reconnect properly. I was also not able to connect with

$ virsh console foo

This only led to

Connected to domain foo
Escape character is ^]

Helpful link to me: https://www.server-world.info/en/note?os=Ubuntu_16.04&p=kvm&f=2

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.