1. Basic installation environment
yum groupinstall Virtualization "Virtualization Client"
yum install libvirt
2. Start Services
systemctl enable libvirtd
systemctl start libvirtd
systemctl status libvirtd
3. The system image preparation
Thunder download the image and upload it to the server
mkdir /openstack-image
cd /openstack-image
ed2k://|file|cn_windows_server_2012_r2_with_update_x64_dvd_6052725.iso|5545705472|121EC13B53882E501C1438237E70810D|/
4. Create a disk file
chown -R qemu:qemu /openstack-image
qemu-img create -f qcow2 ws2012r2-dc.qcow2 20G
5. Prepare windows compatible drive
wget https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.126-2/virtio-win-0.1.126.iso
wget https://cloudbase.it/downloads/CloudbaseInitSetup_0_9_11_x64.msi
6. Start the virtual machine
Since the windows need to download Cloudbase, the network is slow, I will advance at a good document CloudbaseInitSetup_0_9_11_x64.msi packaged into CloudbaseInitSetup_0.9.11_x64.iso, and uploaded to the same server with mirrored windows directory, add the following parameters at startup, while hanging 3 optical carrier to the system to boot-time to complete customized configuration, the NIC driver update, cloudbase installation.
6.1 Using virt-install installation
The use of this method to find a thousand kinds of tools and found not add install image mirroring and drive at the same time until you find this article:
http://bart.vanhauwaert.org/hints/installing-win10-on-KVM.html
qemu-img create -f qcow2 ws2012r2-dc.qcow2 20G
virsh destroy ws2012r2 && virsh undefine ws2012r2
virt-install --name=ws2012r2 --ram=2048 --cpu=host --vcpus=2 \
--os-type=windows --os-variant=win2k12r2 \
--disk ws2012r2-dc.qcow2,bus=virtio \
--disk cn_windows_server_2012_r2_datacenter_with_update_x64_dvd_4048415.iso,device=cdrom,bus=ide \
--disk virtio-win-0.1.126.iso,device=cdrom,bus=ide \
--disk CloudbaseInitSetup_0.9.11_x64.iso,device=cdrom,bus=ide \
--network network=default,model=virtio \
--graphics vnc,listen=0.0.0.0 --noautoconsole
6.2 Installation qemu-kvm
-vnc argument here is ip: digital, that is the default VNC port from the beginning of 5900, with the number specified, 0.0.0.0:0 I set here, it can be directly connected 5900VNC port.
qemu-img create -f qcow2 ws2012r2.qcow2 20G
qemu-kvm -m 2048 -drive file=ws2012r2.qcow2,if=virtio,index=0,media=disk \
-drive file=cn_windows_server_2012_r2_datacenter_with_update_x64_dvd_4048415.iso,index=1,media=cdrom \
-drive file=virtio-win-0.1.126.iso,index=2,media=cdrom \
-drive file=CloudbaseInitSetup_0.9.11_x64.iso,index=3,media=cdrom \
-net nic,model=virtio -net user -boot d -nographic -vnc 0.0.0.0:0
7. Install System
netstat -ntlp | grep qemu-kvm
Find the virtual machine vnc port 5900, using tigerVNC connect and complete the system installed in the console.
ip ip is the server, the default port for the first 5900 and so on, can also command virsh vncdisplay vmname
tigervnc to open the query port, is recommended.
The drive was added
Because windows do not own drivers openstack, the system starts the hard drive can not recognize the need to manually load the driver virtio; NIC driver and driven virtio also required. Because when the virtual machine already mounted the virtio mirror, where you can directly to the computer which are all installed.
8.1 Add a hard disk drive (complete installation)
Click Browse - drive vortio-win-0.1.1, navigate to viostor \ sk12R2 \ amd64:
Click Next to a hard disk can be identified:
On the Device Manager, right-Ethernet controller, browse to the drive following NetKVM, select 2k12R2:
9. Installation cloudbase-init
In the open the drive, double-click the msi file to install cloudbase-init
virt-sparsify --compress ./ws2012r2-dc.qcow2 Windows-Server-2012R2-DC.qcow2
11. Add a mirror to glance
openstack image create "Windows-Server-2012R2-DC" --file ./Windows-Server-2012R2-DC.qcow2 --disk-format qcow2 --container-format bare --public
12. Delete Virtual Machine
To delete a virtual machine from virsh, but the disk will be retained.
virsh list --all
virsh undefine ws2012r2
13. Using existing disk
If you need to re-use the disk to create a virtual machine, use the following command to create
virt-install --name ws2012r2 --memory 2048 --vcpus 2 --disk ws2012r2-dc.qcow2,format=qcow2 \
--import --os-type=windows --os-variant=win2k12r2 \
--disk virtio-win-0.1.126.iso,device=cdrom,bus=ide \
--disk CloudbaseInitSetup_0.9.11_x64.iso,device=cdrom,bus=ide \
--network network=default,model=virtio \
--graphics vnc,listen=0.0.0.0 --noautoconsole
Author: NOZUONOHIGH
link: https: //www.jianshu.com/p/c92c3c9a2d6f#comment-13996075