I'm a bit stuck with virtualization on CentOS 7 using KVM. Whenever I try to create a virtual machine it keeps telling me to connect to the machine via console and finish the installation. Whenever I connect, I can't enter enything, I can only escape from the console.

The way I create the machine:

virt-install --name vm1 --network bridge:br0 --ram=1024 --vcpus=1 --disk path=/var/lib/libvirt/imagesw.img,size=10 --graphics none --location=/mnt/iso

The machine is running, at least that is what

virsh list --all

telling me. How can I finish the installation and begin to use the guest OS from within the server? I have no GUI to access it, I use only terminal.

Thank you in advance!

B.R.: Bert


What you're describing is either a boot system that is not configured with serial console settings, or a VM that does not have a serial device added to it. In most cases, you will have to modify your installer boot options (specifically, kernel arguments) to include something along the lines of console=tty0 console=ttyS0,115200. Also be sure that you have included a serial device in your virt-install line, as I do not see one added. I expound on this later in my answer.

You could use something altogether better suited to this whole task and use virt-builder. This creates virtual machine disk images with fairly generic acceptable defaults in a minimal installation. It's a highly customizable tool, just as virt-install is. Its man page is tremendously well-written.

virt-builder will grab signed virtual machine images from a few dedicated repositories and build a disk image file with those contents (disk image format depending on options chosen). For example, this following command will create a CentOS 7 disk image in qcow2 format, thinly allocated to 20GiB. It will also inject my public ssh key into root's home directory, as well as set the hostname to fubar. Give the man page a good read, as the options go far beyond this.

# virt-builder centos-7 --arch amd64 -o /var/lib/libvirt/images/centos-7.qcow2 --format qcow2 --size 20G --hostname fubar --ssh-inject root:file:~/.ssh/id_rsa.pub

This disk image is ready to connect to a VM, which can be done using virt-install, almost identically to the way you have done it in your question. There will be one big difference, in that we will specify --import alongside --disk so that we point to an existing image rather than make a new one. We also won't be specifying "size" within --disk, as --import excludes that option. Also note that I explicitly added a --serial option, as we need to make sure that device exists to get a console on.

# virt-install --name vm1 --network bridge=br0 --ram=1024 --vcpus=1 --disk path=/var/lib/libvirt/images/vm1.qcow2 --import --nographics --serial=pty --os-type=linux --os-variant rhel7

This will start the "installer" which in this case is just starting the newly provisioned VM and connecting to its serial console.

  • Thanks, never heard of virt-builder. Sounds handy, but in my situation it is not useable I think. I need to work in a completly offline environment, thos I can't pull any image from the web. Actually I've succeeded (sort of) with the follwoing command: virt-install --name=firewall --disk path=/var/lib/libvirt/firewall.img --ram=1024 --vcpus=1 --network bridge:br0 --nographics --os-type=linux --os-variant=rhel7.1 --location /var/lib/libvirt/images/CentOS-7-x86_64-Minimal-1609-99.iso --extra-args console=ttyS0 Now the OS installs, but then it is just standing and can'T do anything in it – Bert Nov 14 '16 at 16:13
  • You need more kernel arguments. Specifically, you have to specify consoles on both tty0 and ttyS0, as well as specifying baud rate. As in: --extra-args console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH. – Spooler Nov 14 '16 at 17:32

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