Making Windows R2 images for OpenStack

Source: Internet
Author: User
Tags connect socket

Prerequisites:

A host that supports hardware-assisted virtualization (Intel vt-x or amd-v).

The installed CentOS7, the default minimum installation, configures the network so that it can access the extranet.

Preparing the Windows R2 installation disc image

Configuration process:

Note: in the following configuration procedure, the eno16777736 is the network card for the host outside, the IP address is 192.168.1.9, in the configuration process, please modify according to the actual situation

    • Environment preparation

Install related Packages

Yum install-y vim wget net-tools bash-completion qemu-kvm libvirt virt-installsystemctl start Libvirtd.service

Create a bridged network

Cat >/etc/libvirt/qemu/networks/bridge.xml << eof<network> <name>bridge</name> < Bridge name= "Br-ex"/> <forward mode= "route" dev= "eno16777736"/> <ip address= "192.168.1.9" netmask= " 255.255.255.0 "/></network>eofvirsh Net-define/etc/libvirt/qemu/networks/bridge.xmlvirsh Net-autostart Bridge

Configure the NIC to be automatically added to the bridge

Cp/etc/sysconfig/network-scripts/ifcfg-eno16777736/etc/sysconfig/network-scripts/ifcfg-br-exsed-i-E '/^NAME=/d ' -E '/^device=/d '-e ' s/^type=.*/type=bridge/'-e '/^uuid=/d '-e '/^hwaddr=/d '/etc/sysconfig/network-scripts/ Ifcfg-br-execho "Device=br-ex" >>/etc/sysconfig/network-scripts/ifcfg-br-exsed-i-E '/^ipaddr/d '-e '/^NETMASK /d '-e '/^prefix/d '-e '/^gateway/d '-e '/^dns/d '/etc/sysconfig/network-scripts/ifcfg-eno16777736echo "BRIDGE=br-ex" & Gt;>/etc/sysconfig/network-scripts/ifcfg-eno16777736

Reboot the system to make the configuration effective

Reboot

Confirm that the bridge network is started

Virsh Net-listbrctl Show

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m02/5a/65/wkiom1t8ks_xyfsraaeram9uxrc456.jpg "style=" Float:none; "title=" 1.png "alt=" Wkiom1t8ks_xyfsraaeram9uxrc456.jpg "/>

Shut down the firewall or open the 5900+n port (to connect the virtual machine console from the client, by default starting with Port 5900, each virtual machine instance consumes a port number, or you can specify the port used by the virtual machine instance)

Systemctl Disable Firewalld.service; Systemctl Stop Firewalld.service

Create a Mirror Authoring directory

Mkdir/opt/image; Cd/opt/image

Download Virtio driver Floppy disk

Wget-o virtio-win-drivers.vfd https://launchpad.net/kvm-guest-drivers-windows/20120712/20120712/+download/ Virtio-win-drivers-20120712-1.vfd


    • Installing the Windows R2 System

Create a virtual disk in QCOW2 format

Qemu-img create-f qcow2 Win2k8.qcow2 10G

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5A/61/wKioL1T8k-rAFlGTAACRPFuyOoY460.jpg "title=" 2.png " Style= "Float:none;" alt= "wkiol1t8k-raflgtaacrpfuyooy460.jpg"/>

Upload the system installation image file to/opt/image (this procedure is not described in this article, skip) and name Win2k8.iso. If you use a different file name, you should modify the image file name yourself in subsequent operations.

If only the disc is not mirrored, you can insert the disc into the CD drive and make the disc into an ISO image using the following command.

DD If=/dev/sr0 Of=/opt/image/win2k8.iso

Create a virtual machine instance. The following command creates an instance of a win2k8 virtual machine with 1 g of memory, a single core CPU, a virtio NIC and a disk adapter, Mount Win2k8.iso and VIRTIO-WIN-DIRVERS.VFD, remote control using Spice (auto-assign port number, default starting from 5900)

Virt-install--connect qemu:///system--VIRT-TYPE=KVM--name win2k8--ram 1024x768--vcpus 1--arch=x86_64--network network=b Ridge,model=virtio--disk win2k8.qcow2,format=qcow2,device=disk,bus=virtio--cdrom win2k8.iso--disk Virtio-win-drivers.vfd,device=floppy--graphics spice,listen=0.0.0.0--video qxl--channel spicevmc--os-type Windows- -os-variant win2k8

The following two alarms can be ignored, and subsequent connections will be made from the Windows client without using the Virt-viewer

    • If Virt-viewer is not installed, a warning message appears WARNING unable to connect to graphical Console:virt-viewer not installed.

    • If you run this command in command-line mode, a warning message appears WARNING * *: Could not open X display

Install Spice client on local windows (download link https://fedorahosted.org/released/virt-viewer/), Linux system can be installed under GUI interface Virt-viewer

When the installation is complete, run the Remote Viewer

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m00/5a/65/wkiom1t8ks-dvl0uaaan9aoc9hk392.jpg "title=" 3.png "style=" Float:none; "alt=" Wkiom1t8ks-dvl0uaaan9aoc9hk392.jpg "/>

Enter Spice://host address in the Connection address field: 5900

If other virtual machine instances are also running, you can use PS Axu | grep win2k8 | grep port= to see the specific port number (no way to find administrative command queries through Virsh)

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m01/5a/61/wkiol1t8k-qybjepaadpsophu4u255.jpg "title=" 4.png "style=" Float:none; "alt=" Wkiol1t8k-qybjepaadpsophu4u255.jpg "/>

Click Connect to open the remote virtual machine installation Interface

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5A/65/wKiom1T8ktGy-l-NAAQIIIO8vXE538.jpg "title=" 5.png " Style= "Float:none;" alt= "wkiom1t8ktgy-l-naaqiiio8vxe538.jpg"/>

Because the Virtio semi-virtualized drives are used, the drivers are not available by default in R2 and Win7, so they need to be manually loaded

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m02/5a/61/wkiol1t8k-ztpomraabouqqmc94737.jpg "title=" 6.png "style=" Float:none; "alt=" Wkiol1t8k-ztpomraabouqqmc94737.jpg "/>

Load the storage driver from the floppy drive (shown here 2003R2, also available for 2008r2. May be the floppy drive capacity is limited, the author did not add too much content)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/65/wKiom1T8ktHS0t-JAADmzZFzx68186.jpg "title=" 7.png " Style= "Float:none;" alt= "wkiom1t8kths0t-jaadmzzfzx68186.jpg"/>650) this.width=650; src=/e/u261/themes/ Default/images/spacer.gif "style=" border:1px solid rgb (221,221,221); background-position:50% 50%;background-repeat: no-repeat; "alt=" Spacer.gif "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5A/61/wKioL1T8k-ziarx6AACCyiD16LQ513.jpg "title=" 8.png " Style= "Float:none;" alt= "wkiol1t8k-ziarx6aaccyid16lq513.jpg"/>

Then click Next and wait a few moments before you can see the disk space allocated earlier.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5A/65/wKiom1T8ktGCK_5ZAACi5mgK4I8435.jpg "title=" 9.png " Style= "Float:none;" alt= "wkiom1t8ktgck_5zaaci5mgk4i8435.jpg"/>

The following system installation steps are omitted. Restarting before the installation is complete causes the spice connection to be disconnected, reconnected, and restarted after the installation is complete and no longer disconnected


After the system installation is complete, install the NIC driver (drive in the floppy drive). Configure the virtual machine network to connect to the external network.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m01/5a/61/wkiol1t8k-zgifvjaaeyf__lwno999.jpg "title=" 10.png "style=" Float:none; "alt=" Wkiol1t8k-zgifvjaaeyf__lwno999.jpg "/>

Download Virtio driver and QXL display driver. (The network is already configured, you can also use RDP to connect virtual machine instances for easy replication of links and files)

(Alternate link http://alt.fedoraproject.org/pub/alt/virtio-win/stable/virtio-win-0.1-81.iso)

Http://www.spice-space.org/download/windows/spice-guest-tools/spice-guest-tools-0.74.exe

Http://www.spice-space.org/download/windows/qxl/qxl-0.1-21/qxl_8k2R2_x64.zip

Install Spice-guest-tools-0.74.exe, install QXL graphics driver

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5A/65/wKiom1T8ktLiGfIKAAFWFvKJzlc616.jpg "title=" 11.png "Style=" Float:none; "alt=" wkiom1t8ktligfikaafwfvkjzlc616.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/61/wKioL1T8k-3g6FLJAAEPGTqJ8Ck204.jpg "title=" 12.png "Style=" Float:none; "alt=" wkiol1t8k-3g6fljaaepgtqj8ck204.jpg "/>

After the installation is complete, the device drivers such as

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/65/wKiom1T8ktKRB_lXAAEushGXEgQ277.jpg "title=" 13.png "Style=" Float:none; "alt=" wkiom1t8ktkrb_lxaaeushgxegq277.jpg "/>

In this case, you can share the Clipboard between the virtual machine instance and the host (based on the Spice Agent), can copy the URL, screenshots and other text and image information, but cannot copy the file.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5A/61/wKioL1T8k-3TPO2BAACMBNgcy-U853.jpg "title=" 14.png "Style=" Float:none; "alt=" wkiol1t8k-3tpo2baacmbngcy-u853.jpg "/>

Install updates, delete temporary files.


    • Configuration system and OpenStack integration

Download the Cloudbase-init tool and install Https://github.com/cloudbase/cloudbase-init

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5A/65/wKiom1T8ktOgxvvgAAGjj1FL1qM564.jpg "title=" 15.png "Style=" Float:none; "alt=" wkiom1t8ktogxvvgaagjj1fl1qm564.jpg "/>650" this.width=650; "src="/e/u261/themes/ Default/images/spacer.gif "style=" border:1px solid rgb (221,221,221); background-position:50% 50%;background-repeat: no-repeat; "alt=" Spacer.gif "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5A/61/wKioL1T8k-7gehnRAAFHefb2pR4840.jpg "title=" 16.png "Style=" Float:none; "alt=" wkiol1t8k-7gehnraafhefb2pr4840.jpg "/>

Choose to perform a Sysprep package

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5A/65/wKiom1T8ktShDXr-AAHTC28Xw6E730.jpg "title=" 17.png "Style=" Float:none; "alt=" wkiom1t8ktshdxr-aahtc28xw6e730.jpg "/>

Modify the NIC configuration to DHCP, delete the temporary files (including the drivers and installation files that were downloaded earlier), and shut down the computer.

When the program is installed, a Cloud initialization service is generated and the service starts automatically the next time it is started.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/61/wKioL1T8k--CqyMyAACtbtdvELo229.jpg "title=" 18.png "Style=" Float:none; "alt=" wkiol1t8k--cqymyaactbtdvelo229.jpg "/>

It receives metadata (http://169.254.169.254) from OpenStack, and then performs a series of initialization operations,

    • Set host name;

    • Create or update the local user (the user name specified during installation, default to Admin), add his local group (separated by commas), and inject the password;

    • Configure the network (the NIC specified during the previous installation);

    • Create a Authorized_keys file with SSH keys in the user directory (provided by the metadata, which is the key pair selected when the instance was created);

    • Executes the script specified when the instance is created (input script, first line is written to rem cmd for batch command, first line is written #ps1 as PowerShell script)

For more information, refer to this link http://www.cloudbase.it/cloud-init-for-windows-instances/

    • Compressing virtual machine disks

Qemu-img convert-c-p-o Qcow2/opt/image/win2k8.qcow2/opt/image/win2k8r2.qcow2

Where-c means compression is used, and-p indicates progress during execution,-o Specifies the output format is Qcow2

Compare before and after file size

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/65/wKiom1T8ktShVNq3AABc-7_5hQA016.jpg "title=" 19.png "Style=" Float:none; "alt=" wkiom1t8ktshvnq3aabc-7_5hqa016.jpg "/>

    • Upload to glance

Copy the virtual machine disk file to the control node and execute the following command to complete the image upload

Glance image-create--name "WINDOWS_2008_R2"--is-public true--disk-format qcow2--container-format bare--file/opt/ima Ge/win2k8r2.qcow2



Troubleshooting:

Failure phenomena:

The following error message appears when you execute Virsh net-list

Error:failed to connect to the hypervisor

Error:no Valid connection

Error:failed to connect socket to '/var/run/libvirt/libvirt-sock ': No such file or directory

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5A/61/wKioL1T8k-_BIyjIAACk13VXc0s330.jpg "title=" 20.png "Style=" Float:none; "alt=" wkiol1t8k-_biyjiaack13vxc0s330.jpg "/>

Cause of the problem:

LIBVIRTD Service not started

Workaround:

Execute Systemctl start Libvirtd.service start the service.

The service health status can be checked by SYSTEMCTL status Libvirtd.service to ensure that the service is in active (running) state

Systemctl Start Libvirtd.servicesystemctl Status Libvirtd.service

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5A/65/wKiom1T8ktThDSkVAAE2qkDR_Ys783.jpg "title=" 21.png "Style=" Float:none; "alt=" wkiom1t8ktthdskvaae2qkdr_ys783.jpg "/>


This article is from the "foolishfish" blog, make sure to keep this source http://foolishfish.blog.51cto.com/3822001/1618447

Making Windows R2 images for OpenStack

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.