6

Short Version (Solution is below):

I have a Windows PC. I have a Debian server (without desktop environment). I have a Ubuntu VM running on Debian server via KVM/QEMU.

Question: How can I connect to Ubuntu VM and start the installation process?

Long Version (Solution is below):

Situation

I have some experience with Linux but I am quite new to virtualisation on Linux. I want to create multiple Virtual Machines on my Debian server. I connect from my Windows PC over ssh to the Debian server. The Debian server does not have any desktop environment installed. I used the following tutorial https://www.howtoforge.com/virtualization-with-kvm-on-a-debian-squeeze-server, but on step 3 it told me to install virt-manager which is a graphical tool. As expected i cannot start virt-manager over ssh.

Question

How can i connect to the VM and install the Operating system as well as a sshd server. I want to connect to my VM over ssh after the initial installation.

Possible Solution A

I found out that i can connect to the Virtual Machine over VNC, some tutorials tell me to ssh from Windows to Debian with a Port Forward and then start a VNC Client on Windows. However it wont connect to the VNC because i don't know how to configure the VM or virsh to use the right port.

Possible Solution B

This Ubuntu Tutorial shows a way to connect directly via console: https://help.ubuntu.com/community/KVM/Access I would like to use this method but it needs upstart and i dont want to deinstall my systemd-sysv. The turorial is made for Ubuntu 9.4

Possible Solution C

If i had a Ubuntu.iso which would automaticly run a sshd server i could directly connect to the installer via ssh. But i haven't found one or know how to create one.

Solution:

I found the solution for this problem.

  1. Check if KVM will run on system. you CPU should support vmx or svm egrep '(vmx|svm)' --color=always /proc/cpuinfo
  2. Install KVM on Physical Machine running Debian sudo apt-get install kvm qemu-kvm libvirt-bin virtinst
  3. test virtinst installation with and exit virsh -c qemu:///system list
  4. Optional: Install a Bridge interface, google for tutorial here.
  5. Download iso file from website wia wget wget http://link.to.your.linux.distro.iso
  6. Install a new VM with the following command virt-install --connect qemu:///system --name your_vm_name --memory 512 --cdrom /srv/vmimage/ubuntu-14.04.4-server-amd64.iso --disk size=8 --noautoconsole --os-type linux --accelerate --network=bridge:br0 --hvm --graphics vnc,port=5900,listen=0.0.0.0
    I am no expert but try to explain some of the options:
    --disk size=8: will create a disk with 8 GB size --network=bridge:br0: VM will access internet over bridge interface created, replace br0 with the name of your bridge if you have one
    --graphics vnc,port=5900,listen=0.0.0.0: Use VNC Protocol to display Graphics on port 5900.

Now you should see an output like this:

Domain installation still in progress. You can reconnect to the console to complete the installation process.
  1. Fine your VM ist running now, you just need to connect to it. Switch to your Windows Machine(or whatever you use to ssh to the Debian Server) On windows you need some VNC tool, I used TightVNC Viewer. Install it.
  2. You need some ssh shell, I recommend to install the Git Scm under Windows.
  3. On Windows: Open a Shell via Git Scm and switch to your TightVNC dir.
  4. Now Open a Port forwarding from Windows to Debian Server, via command ssh -L 5900:localhost:5900 -N -f yourusername@yourserverip. Replace yourusername and yourserverip with the Debian Username and IP. This will make it possible for your VNC Viewer to connect to the Virtual Machine
  5. Now start tvnviewer.exe and connect to 127.0.0.1:5900. A new windows should open with your new VM. Profit, you made it :)

closed as off-topic by MadHatter, HopelessN00b, Roman, Jim B, mdpc Feb 29 '16 at 23:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow." – MadHatter, HopelessN00b, Roman, Jim B, mdpc
If this question can be reworded to fit the rules in the help center, please edit the question.

4

KVM and it's derivatives have a VNC server in its video subsystem. So you have to take a VNC client (any from widely availables), configure your KVM VM machine with a VNC connection (I usually do this by supplying a --graphics vnc,port=5900,listen=0.0.0.0 option to the virt-install program) and use it to remotely install any operating system you want. This is a general method of accessing a "local console".

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