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):
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.
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.
I found the solution for this problem.
- Check if KVM will run on system. you CPU should support vmx or svm
egrep '(vmx|svm)' --color=always /proc/cpuinfo
- Install KVM on Physical Machine running Debian
sudo apt-get install kvm qemu-kvm libvirt-bin virtinst
- test virtinst installation with and exit
virsh -c qemu:///system list
- Optional: Install a Bridge interface, google for tutorial here.
- Download iso file from website wia wget
- 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.
- 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.
- You need some ssh shell, I recommend to install the Git Scm under Windows.
- On Windows: Open a Shell via Git Scm and switch to your TightVNC dir.
- 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
- 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 :)