Start KVM VM from scratch - need Help!


Recommended Posts

Hi Guys.

 

I'm really new to this whole VM thing. But I have plenty of ideas what I want to do.

So I give VM a try. I want to make a new VM from scratch. but it fails.

 

My Machine:

Kernel: Linux 3.15.0-unRAID x86_64
Motherboard: ASUSTeK COMPUTER INC. - AM1M-A
CPU: AMD Athlon(tm) 5350 APU with Radeon(tm) R3
Speed: 2.05 GHz
Memory: 4096 MB (max. 4 GB)
Network: br0: - Duplex
docker0: - Duplex
eth0: 1000Mb/s - Full Duplex 
Unraid 6b6

 

What I am doing right now:

 

mkdir /mnt/cache/vm/Ubuntu_VM
cd /mnt/cache/vm/Ubuntu_VM
qemu-img create cqow2 ubuntu.img 20G
wget http://<path-to>/ubuntu-14.04-desktop-amd64.iso 
qemu-system-x86_64 -hda ubuntu.img -cdrom ubuntu-14.04-desktop-amd64.iso -boot d -m 1024 

 

Then it seems to start, and the console says it starts vnc on 127.0.0.1:5900 but after some time the whole server isn't responding anymore and I have to do a hard reset. I also tried it with Arch - same result.

 

Can you please help me?

Is there a guide to set up a VM in unraid?

 

Regards

Owel

 

Link to comment

Look at the xml file instead

 

below is my CentOS 7 domain file.

 

<domain type='kvm'>
  <name>CentOS</name>
  <uuid>ba6891bd-32cf-2236-2525-6e12bb490e9e</uuid>

  <memory unit='GB'>2</memory>
  <currentMemory unit='GB'>2</currentMemory>

  <vcpu placement='static'>2</vcpu>
  <cpu mode='host-passthrough'>
    <topology sockets='1' cores='1' threads='2'/>
  </cpu>

  <os>
    <type arch='x86_64' machine='q35'>hvm</type>
   <loader>/usr/share/qemu/bios-256k.bin</loader>
    <boot dev='cdrom'/>
  </os>

  <features>
    <acpi/>
    <apic eoi='on'/>
    <pae/>
  </features>

  <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='yes'/>
  </clock>


  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>

  <devices>

    <emulator>/usr/bin/qemu-system-x86_64</emulator>

<disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/vm_disk/KVM/ISO/CentOS-7.0-1406-x86_64-DVD.iso'/>
      <backingStore/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
    </disk>


    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/mnt/vm_disk/KVM/CentOS/CentOS.qcow2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
    </disk>

    <controller type='ide' index='0'>
    </controller>
    <controller type='sata' index='0'>
    </controller>
    <controller type='pci' index='0' model='pcie-root'>
    </controller>
    <controller type='pci' index='1' model='dmi-to-pci-bridge'>
    </controller>
    <controller type='pci' index='2' model='pci-bridge'>
    </controller>

   <interface type='bridge'>
      <source bridge='br0'/>
      <model type='virtio'/>
    </interface>

    <serial type='pty'>
      <source path='/dev/pts/2'/>
      <target port='0'/>
    </serial>

    <console type='pty' tty='/dev/pts/2'>
      <source path='/dev/pts/2'/>
      <target type='serial' port='0'/>
    </console>

    <input type='mouse' bus='ps2'/>

    <graphics type='vnc' port='5900' autoport='yes' listen='192.168.0.190' keymap='sv'>
      <listen type='address' address='192.168.0.190'/>
    </graphics>

    <video>
      <model type='cirrus' vram='9216' heads='1'/>
    </video>

    <memballoon model='virtio'>
    </memballoon>

  </devices>
</domain>

 

Change the path to HD, cdrom,name of your VM, CPU, memory, VNC listen and bridge name

 

Create a qcow2 images

 

qemu-img create -f qcow2 CentOS.qcow2 30G

 

 

Start the VM

virsh create CentOS.xml

 

After VM are installed, change this line

 

   <boot dev='cdrom'/>

To

   <boot dev='hd'/>

 

to boot from from the image, then

virsh create CentOS.xml

 

 

Some virsh commands

 

List domains

virsh list

Shutdown

virsh shutdown CentOS

 

reboot

virsh reboot CentOS

 

destroy

virsh destroy CentOS

 

To view the details of the VM

virsh dumpxml CentOS

 

Start a defined machine

virsh start CentOS

 

Enable virsh console on system with Grub2 & systemd

 

nano /etc/default/grub

On line GRUB_CMDLINE_LINUX add

console=ttyS0,115200

update grub

grub2-mkconfig -o /boot/grub2/grub.cfg

Enable ttyS0

systemctl start [email protected]

Check status

systemctl status [email protected]

Enable autostart of ttyS0 during boot

systemctl enable [email protected]

 

reboot

Link to comment

Thanks peter_sm for your help.

 

i adopted your cfg to me needs:

<domain type='kvm'>
  <name>Ubuntu</name>
  <uuid>ba6891bd-32cf-2236-2525-6e12bb490e9e</uuid>

  <memory unit='GB'>2</memory>
  <currentMemory unit='GB'>2</currentMemory>

  <vcpu placement='static'>2</vcpu>
  <cpu mode='host-passthrough'>
    <topology sockets='1' cores='1' threads='2'/>
  </cpu>

  <os>
    <type arch='x86_64' machine='q35'>hvm</type>
   <loader>/usr/share/qemu/bios-256k.bin</loader>
    <boot dev='cdrom'/>
  </os>

  <features>
    <acpi/>
    <apic eoi='on'/>
    <pae/>
  </features>

  <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='yes'/>
  </clock>


  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>

  <devices>

    <emulator>/usr/bin/qemu-system-x86_64</emulator>

<disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/cache/vm/Ubuntu_VM/ubuntu-14.04-desktop-amd64.iso'/>
      <backingStore/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
    </disk>


    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/mnt/cache/vm/Ubuntu_VM/ubuntu.qcow2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
    </disk>

    <controller type='ide' index='0'>
    </controller>
    <controller type='sata' index='0'>
    </controller>
    <controller type='pci' index='0' model='pcie-root'>
    </controller>
    <controller type='pci' index='1' model='dmi-to-pci-bridge'>
    </controller>
    <controller type='pci' index='2' model='pci-bridge'>
    </controller>

   <interface type='bridge'>
      <source bridge='br0'/>
      <model type='virtio'/>
    </interface>

    <serial type='pty'>
      <source path='/dev/pts/2'/>
      <target port='0'/>
    </serial>

    <console type='pty' tty='/dev/pts/2'>
      <source path='/dev/pts/2'/>
      <target type='serial' port='0'/>
    </console>

    <input type='mouse' bus='ps2'/>

    <graphics type='vnc' port='5900' autoport='yes' listen='192.168.178.11' keymap='de'>
      <listen type='address' address='192.168.178.11'/>
    </graphics>

    <video>
      <model type='cirrus' vram='9216' heads='1'/>
    </video>

    <memballoon model='virtio'>
    </memballoon>

  </devices>
</domain>

 

Then i create this VM und virsh list tells me it is running.

Also my router recognizes a new machine on the network.

 

But I'm unable to connect vnc.

Any help?

Link to comment

What VNC software are u using ?

 

you should connect on192.168.178.11:5900, if this IP is your UnRAID, or try other ports 5901 .....

 

 

There are also a way to connect using

 

virsh console CentOS

 

But that needs some tweak on the bootloader for the VM, and also setup tttyS0 on the VM, you can easily google "virsh console ubuntu"

//Peter

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.