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

目录
相关文章
|
21天前
|
人工智能 JavaScript 开发工具
极速上手!Claude Code 原生支持 Windows 免WSL安装教程
Claude Code 现已支持 Windows 原生运行,无需 WSL 配置。本文提供详细安装教程,涵盖 Node.js 环境验证、Git 安装及 Claude Code 配置步骤,助你快速上手这一强大 AI 编程工具。
450 5
|
2月前
|
Ubuntu Unix Linux
在Windows上轻松安装和使用Ubuntu的方法详解
继续点击“Continue”按钮以继续安装流程,随后选择清理磁盘并安装操作系统的选项。 接下来,在安装过程中,你需要选择时区。为了与你的地理位置相匹配,请选择中国上海作为你的时区设置。 在安装过程中,你还需要设置计算机的名称以及账号密码。请务必牢记这些信息,因为它们将作为你登录系统的凭证。
|
1月前
|
存储 虚拟化 Windows
VMware安装Windows10
本案例介绍了在Windows系统上使用VMware Workstation 17.5 Pro安装配置Windows 10虚拟机的详细步骤,包括所需设备、软件下载链接、虚拟机设置及系统安装全过程。
VMware安装Windows10
|
2月前
|
Ubuntu Linux Windows
如何在Ubuntu系统中安装Wine,借此来运行Windows程序
熟悉的登录画面出现,在Ubuntu系统中扫描登录微信程序。
|
2月前
|
Ubuntu Linux Shell
手把手教你安装适用于Linux的Windows子系统——Ubuntu
重启完成,你看看重新打开Ubuntu是不是发生了变化,等待几分钟,系统配置完成,根据提示设置用户名和密码即可
|
2月前
|
Ubuntu Linux 数据安全/隐私保护
Windows上快速安装Linux子系统Ubuntu
Installing, this may take a few minutes...WslRegisterDistribution failed with error: 0x800701bcError: 0x800701bc WSL 2 ?????????????????? https://aka.ms/wsl2kernelPress any key to continue... 原因是 wsl1 升级到 wsl2 之后,内核却没有升级。 解决:下载最新的wsl安装包(wsl安装包)
|
3月前
|
运维 Linux 虚拟化
VMware虚拟机安装教程,Windows下安装VMware虚拟机,附VMware下载,Windows各版本系统镜像下载
虚拟机技术允许一台物理机运行多个操作系统,提升资源利用率,节省成本。通过快照、克隆等功能,实现系统快速恢复与复制,提高运维效率。本文详细介绍VMware虚拟机的安装步骤、Windows镜像下载及系统安装激活流程,适合初学者快速入门。
812 0
|
3月前
|
Linux Docker Windows
windows docker安装报错适用于 Linux 的 Windows 子系统必须更新到最新版本才能继续。可通过运行 “wsl.exe --update” 进行更新。
适用于 Linux 的 Windows 子系统需更新至最新版本(如 wsl.2.4.11.0.x64.msi)以解决 2025 年 Windows 更新后可能出现的兼容性问题。用户可通过运行 “wsl.exe --update” 或访问提供的链接下载升级包进行更新。
897 0