Windows server 2012 r2 kvm

# conncet to host with ssh and vnc port tunnel
ssh $USER@$HOST -L 5901:localhost:5901

# create disk image
qemu-img create -f qcow2 /var/lib/libvirt/images/win12r2.qcow2 32G

# download virtio iso
curl -sSL https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso > /var/lib/libvirt/images/iso/virtio-win.iso

# install
virt-install \
  --name win12r2 \
  --ram 2048 \
  --vcpus=2 \
  --disk path=/var/lib/libvirt/images/win12r2.qcow2,format=qcow2 \
  --network 'model=virtio,bridge=br0' \
  --graphics vnc,port=5901,password=test \
  --disk 'device=cdrom,path=/var/lib/libvirt/images/iso/SW_DVD9_NTRL_Windows_Svrs_2012_R2_English_2_FPP_OEM_Std_DC_X19-82429.ISO' \
  --disk 'device=cdrom,path=/var/lib/libvirt/images/iso/virtio-win.iso'  \
  --os-type=windows \
  --os-variant=win2k12r2 \
  --boot cdrom,hd 
 
# connect vnc on localhost:5901

I recently had a need to create a KVM image of Windows 2012
server.  I thought I would take the time
to show how to do it here.

I am going to show how to do it via Ubuntu 14.04.3 Desktop
that itself running as a VM on a VMware Workstation 10.

VMware Workstation 10

You can skip this if you don’t plan on creating an Ubuntu
desktop image on VMWare Workstation.

I am not going to go over in detail how to set up an Ubuntu
image that can run KVM from within Workstation but I want to cover the big
gotchas.

You do need to have processor that supports virtualization.

Hard drive

For the hard drive I allocated all disk space now and stored
it as a single disk hoping that would help a little.  (You don’t have to do this)

Select Processors and checkbox Virtualize Intel VT-x/EPT or
AMD-V/RVI

Let it build the Ubuntu VM out.  J

Confirm you can install KVM

Before you start make sure Ubuntu has Access to VT-x tech on
your chip.

Open up a terminal and run this command.

  > egrep -c
‘(vmx|svm)’ /proc/cpuinfo

Must be greater than 0 and your probably good to go.

Install KVM

I ran this from a fresh install of Ubuntu 14.04.3 Desktop

Run the following command to install the KVM and associated
tools

  > sudo apt-get
install -y qemu-kvm qemu-system libvirt-bin ubuntu-vm-builder bridge-utils
kvm virtinst virt-manager

I always like to reboot my machine after installing all the
tools I need.

   > virsh -c
qemu:///system list

I got an error at this point

error: failed to connect to the
hypervisor

error: Failed to connect socket
to ‘/var/run/libvirt/libvirt-sock’: No such file or directory

During one installation I got
this error… I tried to figure out why and found a few sites.

Since I was using a fresh install
of Ubuntu 14.04.3 I just did a fresh install and tried this procedure.

Run the following command to install the KVM and associated tools

  > sudo apt-get
install -y qemu-kvm qemu-system libvirt-bin ubuntu-vm-builder bridge-utils
kvm virtinst virt-manager

Log out, then Log back in

   > virsh -c
qemu:///system list

That is the response we want.

After reboot verify again. Verify
installation

   > virsh -c
qemu:///system list

Download Virtio ISO

You need to download some Windows Drivers that will are
required for windows to run on KVM.

Grab a Windows 2012 ISO trial version

You need to sign in to your MS account (or make one if you
do not have one)

Select ISO and click Register to Continue.

Fill out your information and click continue.

Fill out your info and 
Click Continue

It’s over 4GiB so it may take a while to download J

I moved the Virt ISO and Win ISO to the desktop.

Start Virtual Machine Manager

Search for Virtual and start up Virtual Machine Manager.

Click Create new machine.

Give it a name and click Forward.

Find your windows ISO, in my case I put it on the
Desktop.  Select it and click Open.

Set the memory and CPU #.  I think 2GiB
is a minimum.  Click Forward.

Set the Disk Size.  I
am setting it to 15GiB which is pretty small for Windows.  I am doing this because I am going to move
this virtual machine around.  I am not
going to install any updates or any software it’s going to be a base VM.

Click forward.

Checkbox Customize Configuration before Install and click
Forward.

Select NIC and choose virtio from the pull down.

Select Disk,  From the
advanced option select Virtio for Disk bus and click apply.

Select Storage, 
Select  managed or other existing
storage. 
For Device type select IDE CDROM.

Select Desktop and select Virtio-win iso and click Open.

It starts to create the machine.

Make the VM window bigger so you can see that it is loading
files.

Do not forget ctrl+alt will get you out of the VM window.

Select the version you want and click Next (I chose Standard
Evaluation with a GUI)

Accept the License and click Next.

Load Drivers

Now comes the fun part… Loading drivers from the virtio ISO.

Select Ballon à 2k12R2 à amd64 and click Ok.

It should run a scan of the driver now.

Select NetKVM à 2k12R2 à amd64 and click Ok.

It should run a scan of the driver now.

Select viorng à 2k12R2 à amd64 and click Ok.

Uncheck Hide drivers, select Driver

It should run a scan of the driver now.

Select vioscsi à 2k12R2 à
amd64 and click Ok.

Uncheck Hide drivers, select Driver

It should run a scan of the driver now.

Select vioserial à 2k12R2 à
amd64 and click Ok.

Uncheck Hide drivers, select Driver

It should run a scan of the driver now.

Click Load Driver again

Select viostor à 2k12R2 à
amd64 and click Ok.

Uncheck Hide drivers, select Driver

It should run a scan of the driver now.

Now you can see the drive!

Select it and click Next.

Set your Administrator password and click finish.

From the menubar select Send Key -> Ctrl+Alt+Delete

Put in your password and log in.

In case you want to move it…

In case you want to copy the raw image here is a little bit
of help.

From  the pull down
select Shut Down

Open a terminal and go to

  > cd
/var/lib/libvirt/images

Just copy it and move it.

If you are in a situation like me and uploading a 15GiB file
may be problematic… Split it up using the split command.  … Of course first you should gzip it!

(the -k will keep the original in place)

  > sudo gzip -k
win-2012-eval.img

  > mkdir  ~/split

  > sudo mv win-2012-eval.img.gz
~/split

  > cd ~/split

  > sudo chown patman:patman win-2012-eval.img.gz

  > split -b 250M win-2012-eval.img.gz

Then rsync them somewhere….

And to put them back together run the following. And gunzip
it.

  > cat x* > win-2012-eval.img.gz

  > gunzip win-2012-eval.img.gz

References

[1]        Nested KVM VM inside a VMware Workstation 8 VM – how to

                Accessed 12/2015

[3]        LibVirt failed to connect to Hypervisor

[4]        B.2.2. Failed to connect socket … : Permission denied

[5]        Window virtio iso

[6]        Windows 2012 r2 server

  1. Get your win2kr2 ISO ready.
  2. Download the drivers iso here: virtio-win.iso
  3. Download KVM config file here: win2kr2.xml
  4. Import the xml file into “Virtual Machine Manager”
  5. Edit win2k12r2 machine in “Virtual Machine Manager”
    1. Add new 25GB virtio storage drive. Make sure to change type from “IDE” to “VirtIO”.
    2. Add cdrom drive connected to virtio-win.iso
    3. Connect your install iso to CD-ROM1
    4. change boot order make the install disc boot first.
  6. Run the machine and install win2012r2 server! Be sure to click “Custom” when installing, so you can search the drivers CD for your virtual storage drivers.

We are moving out! An updated post can be found here:

https://www.cloud-native-everything.com/install-windows-2012r2-in-kvm/

Not a fan. Some app requires windows though. I want to stay with KVM on Centos. Then @hballesteros and I figured (after some saint google search) to install windows loading the virtio drives from a cdrom iso over the setup process.
1. First of all you need to have the iso media (cdrom) and download it at your KVM (i.e. evaluation version at https://www.microsoft.com/en-US/evalcenter/evaluate-windows-server-2012-r2). Rename it to Rename it to ‘/var/lib/libvirt/images/win2012/win2012.iso’
2. Now download the iso image with the virtio drivers form https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.126-2/virtio-win.iso (stable version). Rename it to ‘/var/lib/libvirt/images/win2012/virtio-win.iso’
3. Create a disk:

qemu-img create -f raw /var/lib/libvirt/images/win2012/win2012.img 80GB

4. Create you domain using the following xml:

  win2012
  16777207
  8
  
    /machine
  
  
    hvm
    
    
  
  
    
    
    
      
      
      
    
  
  
    Broadwell
  
  
    
    
    
    
  
  destroy
  restart
  restart
  
    
    
  
  
    /usr/libexec/qemu-kvm
    
      
      
      
      
      <address />
    
    
      
      
      
      
      <address />
    
    
      
      
      
      
      
      <address />
    
    
      
      <address />
    
    
      
      
      <address />
    
    
      
      
      <address />
    
    
      
      
      <address />
    
    
      
    
    
      
      
      
        
      
      
      
      
      <address />
    
    
      
      
      
    
    
      
      
      
    
    
      
      <address />
    
    
      
    
    
      
    
    
      	
    
    <video>
      
      
      <address />
    </video>
    
      
      <address />
    
  
  
  
    +107:+107
    +107:+107
  

  1. Define and start your server via:
virsh define win2012.xml
virsh start win2012

6. Connect thru vnc and load the drivers for storage and network interface as the following
I got the following images from https://serverfault.com/questions/703675/install-windows-2012-r2-over-kvm-virtualizaton

When you are on this step:

Load disk drivers as follow from secondary cdrom:

See ya!

You’ll need to obtain the latest virtio-win-<version>.iso file and copy this to you host, alongside the Windows Server 2012 R2 ISO. Get the former from here: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/

Both of these ISO’s will be mounted on the guest as you’ll have to manually load the virtstor drivers during Windows setup.

Use the code below to create the guest machine, this assumes you have copied ISO images to /var/kvm/images/iso:

sudo virt-install \
--name vwinguest1 \
--ram 2048 \
--disk path=/var/kvm/images/vm/vwinguest1.qcow2,size=16,bus=virtio,format=qcow2 \
--disk /var/kvm/images/iso/win2012r2.ISO,device=cdrom,bus=ide \
--disk /var/kvm/images/iso/virtio-win.iso,device=cdrom,bus=ide \
--vcpus 1 \
--os-type windows \
--os-variant win2k12r2 \
--network bridge=br0,model=virtio \
--graphics vnc,listen=0.0.0.0 \
--noautoconsole \
--accelerate \
--console pty,target_type=serial

Now open KVM and connect to the host IP on port 5901 (or the next free VNC port if you have other guests running with VNC graphics on this host).

Use the code below to auto-start the VMs on host start-up:

sudo virsh autostart vwindc1

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Не удается создать диск восстановления windows 10 отсутствуют некоторые обязательные файлы
  • Canon lbp6020b драйвер windows 10 x64
  • Sherlock holmes chapter one windows 7
  • Копирование файлов windows 0 процентов с флешки
  • Как удалить остатки удаленных программ в windows 10