kvm安装Windows7旗舰版(二)

简介: kvm安装Windows7旗舰版

三,上述环境搭建完毕后,就可以正式的安装啦。


(1),

生成一个img文件,该文件格式为qcow2,命令为:

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

此命令会生成一个img文件,该文件格式是qcow2,一会将会把Windows系统安装到这个文件内。文件存放位置为当前路径下,最好是移动到/opt目录下,如果是root目录下,会有权限问题。

(2),

Windows7纯净版ISO文件和virt驱动文件也在/opt目录下

[root@slave1 opt]# pwd
/opt
[root@slave1 opt]# ll
total 13423720
-rw-r--r-- 1 qemu qemu  3419052032 May  3 21:53 cn_windows_7_ultimate_with_sp1_x64_dvd_618537(1).iso
drwxr-xr-x 2 root root           6 Mar 26  2015 rh
-rw-r--r-- 1 qemu qemu   160755712 May  3 21:51 virtio-win-0.1.102.iso

(3)

正式的安装命令,该命令将会启动一个服务,此服务可以通过vnc连接。端口定义为5922

virt-install --name win7 --os-variant=win7 --ram 512 --vcpus=1 --disk path=/opt/win7.img,size=30,format=qcow2,bus=ide --accelerate --disk device=cdrom,path=/opt/cn_windows_7_ultimate_with_sp1_x64_dvd_618537\(1\).iso --disk device=cdrom,path=/opt/virtio-win-0.1.102.iso --vnc --vncport=5922 --vnclisten=0.0.0.0 --network bridge=br0,model=virtio --noautoconsole

(4)

这里需要注意了,由于是虚拟机套虚拟机,因此,安装的时候需要将CPU定义为映射。定义的方法为:首先先在host上执行virsh -c qemu:///system进入libvirt的shell。然后edit {你的虚拟机名字}。这里由于上面的定义名称是win7,因此,是edit win7 即可,此时就会打开/etc/libvirt/qemu/下的一个名为win7的xml文件。

那么,我们直接打开这个文件然后修改可以吗?这样的修改是不可以的,必须是libvirt的shell修改才会即时生效的哦。这里要注意了。~!!!!!!!!!!

这个文件的内容应该是这样的:

<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
  virsh edit win7
or other application using the libvirt API.
-->
<domain type='kvm'>
  <name>win7</name>
  <uuid>03dc4185-7581-4c1e-9c13-f1f67cedba1f</uuid>
  <memory unit='KiB'>524288</memory>
  <currentMemory unit='KiB'>524288</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-i440fx-rhel7.6.0'>hvm</type>
    <boot dev='hd'/>
    <bootmenu enable='yes'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
    </hyperv>
  </features>
  <cpu mode='host-passthrough' check='partial'>
    <model fallback='allow'/>
  </cpu>
  <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
    <timer name='hypervclock' present='yes'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/opt/win7.img'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/opt/cn_windows_7_ultimate_with_sp1_x64_dvd_618537(1).iso'/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/opt/virtio-win-0.1.102.iso'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:87:6e:6b'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <input type='tablet' bus='usb'>
      <address type='usb' bus='0' port='1'/>
    </input>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='5922' autoport='no' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <video>
      <model type='vga' vram='16384' heads='1' primary='yes'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </memballoon>
  </devices>
</domain>

其中   这个mode的原值是host-model,修改成host-passthrough映射模式。如果不修改,将会在安装的时候一直卡在startwindows那个界面。

这个配置文件里定义了上面那两个文件,也就是那两个ISO文件的存放路径,也就是类似这样的定义:

source file='/opt/cn_windows_7_ultimate_with_sp1_x64_dvd_618537(1).iso'

这里又得注意了,三个设备,安装磁盘win7.img 和挂载的两个ISO光驱格式都是bus='ide',如果用别的格式,比如virt,那么,安装的时候第一次重启后,将会无法再开机的哦。

我们发现一个问题,这个时候还没有开始安装系统,但启动的时候是直接启动硬盘的,原因是有一个地方没有更改

<os>
    <type arch='x86_64' machine='pc-i440fx-rhel7.6.0'>hvm</type>
    <boot dev='hd'/>
  </os>

上述内容里,将hd更改为cdrom即可从cdrom启动啦。

(四)Windows的安装


396a7d6a47e1418f917a313c3712a001.png

5dd2d2ee78984330bb5843cfc4d38a29.png

f9a667ca0d674fe2bb450f60f20719f4.png

ca2cf533954b4af68de17a3e2694ca87.png

910354111532457b9d04cd2c6ddcf190.png

fc6324c5f36e427c816e996b73f1ad10.png

f62713eedaea40fb8532709c62cb2e12.png

556c015aac6141f58f7776b006d40430.png

eb0d7e88dfca4b949bf20048512e5d22.png

目录
相关文章
|
10天前
|
Windows
Windows 系统下安装
安装Julia on Windows: Download the installer from &lt;https://julialang.org/downloads/&gt;; 32-bit works on both 32/64-bit systems, while 64-bit requires 64-bit Windows. Run the installer, clicking Next, and check &quot;Add Julia To PATH&quot; to enable command line usage. Default install dir:
|
21天前
|
并行计算 C++ 异构计算
【环境配置】安装windows版本的TensorRt
【环境配置】安装windows版本的TensorRt
27 4
|
1天前
|
Oracle Java 关系型数据库
02. 【Java教程】Windows 上安装 Java
02. 【Java教程】Windows 上安装 Java
5 1
|
4天前
|
Windows
Windows 系统下安装
**安装Windows上的Julia:** 访问[julialang.org/downloads](https://julialang.org/downloads/)下载安装程序。32位版兼容32/64位系统,但64位版仅适用于64位Windows。安装时,选择&quot;Add Julia To PATH&quot;以添加到环境变量,简化后续命令行使用。默认路径如C:\Users\BAIDU\AppData\Local\Programs\Julia 1.7.2。只需简单下一步安装。
|
9天前
|
Windows
如何使用GUID硬盘分区格式安装新windows系统
这篇文章介绍了全局唯一标识分区表(GUID Partition Table, GPT)与主引导记录(Master Boot Record, MBR)两种硬盘分区格式的区别。
15 0
|
11天前
|
Shell 开发工具 Android开发
|
12天前
|
Windows
苹果笔记本如何安装windows系统
苹果笔记本如何安装windows系统
18 1
|
17天前
|
Windows
Windows 系统下安装
在Windows上安装Julia,访问[julialang.org/downloads](https://julialang.org/downloads/)下载安装程序。64位版本适用于64位系统,32位兼容x86和x86_64。运行安装向导,一路点击Next,记得选中“Add Julia To PATH”选项以添加到环境变量。完成后,用户可在命令行中直接使用Julia,默认路径如C:\Users\BAIDU\AppData\Local\Programs\Julia 1.7.2。
|
21天前
|
TensorFlow 算法框架/工具 C++
在有GPU的windows上安装TensorFlow
在有GPU的windows上安装TensorFlow
33 0
|
21天前
|
Windows
Windows 系统下安装
安装Windows版Julia:访问[julialang.org/downloads](https://julialang.org/downloads/)下载安装程序。64位Julia适用于64位Windows,32位兼容32/64位系统。运行安装向导,一路点击Next,选中&quot;Add Julia To PATH&quot;选项以添加到系统路径。完成后,即可在终端使用Julia命令。默认安装路径:C:\Users\BAIDU\AppData\Local\Programs\Julia 1.7.2。