How to install an Ubuntu 12.04 server VM with virt-install without graphics locally (preferably from an ISO)

pxe-bootubuntu-12.04virt-install

I've seen similar questions here but they don't seem to answer the question, instead deferring to graphical installs or PXE-based installs (and with little detail on the latter for my use case).

I want to create a VM in Ubuntu 12.04 with the Ubuntu 12.04 server ISO and virt-install, locally, using a console (non-graphical) interface. Since you aren't allowed to specify "–extra-args" when using an ISO, my options are evidently limited in getting a standard text-only console.

I've successfully started an install using PXE from a remote repository (see note at the end of this post), but I'd prefer to do this entirely locally, without graphics and network overhead. As I'm installing from the server ISO one would thing it ideally suited to performing a text-only install. (What if your only option is a serial interface to the box?)

If PXE is unavoidable, what's the simplest way to accomplish that locally? Can one avoid installing a web server solely for this thing to access a few local files?

Also, how will the system differ if I build it with PXE the normal ISO? Will they be indistinguishable, or does the PXE-based install add or remove things from the normal install?

An example of what doesn't work:

sudo virt-install --name ubuntu1204os --ram 1024 --arch x86_64 --vcpus 1 \
  --os-type=linux --os-variant=virtio26 --file=/myvms/ubuntu1204os.img \
  --file-size=4 --graphics none --accelerate --hvm --network bridge:virbr0 \
  --cdrom=/myvms/media/ubuntu-12.04-server-amd64.iso

Output:

Starting install...
Creating storage file ubuntu1204os.img                                                                                                   | 4.0 GB     00:00
Creating domain...                                                                                                                       |    0 B     00:00
Connected to domain ubuntu1204os
Escape character is ^]    

<console hangs here>

For reference, instead of the –cdrom option I can use the following options to perform a PXE install, but the point here is to do all this locally, ideally with the ISO alone — unless that's impossible.

  --location http://archive.ubuntu.com/ubuntu/dists/precise/main/installer-amd64/ \
  --extra-args='console=tty0 console=ttyS0,115200n8'

Edit: Actually, the PXE install hangs too but not before asking several install-related questions (e.g., keyboard type, etc., via a pseudo-graphical text interface). It specifically seems to hang after it gets the (default) name of the archive to use, and starts downloading the release files. Thoughts?

Best Answer

I think you're missing a --graphics option to tell it to use VNC. Then you control it using any free VNC / remote desktop client from even a netbook. Here's how I did it:

virt-install --name=ubuntu-vm --os-variant=ubuntuquantal --ram=2048 --vcpus=2 \
--cdrom=/public/software/linux/iso/ubuntu-12.10-desktop-amd64.iso \
--disk path=/srv/vm/ubuntu.img,size=16 \
--network model=virtio \
--graphics vnc,listen=192.168.0.99,port=5906

0.99 is my server IP - use yours as appropriate and whatever iso / path you want for the cdrom. I'm looking into PXE though now too but the above doesn't need it.