Centos7制作Openstack下win7 镜像

编程知识 更新时间:2023-04-18 13:20:01

1 安装Centos7系统

2 验证系统是否支持虚拟化?

[root@localhost ~]# egrep '(vmx|svm)' -o  /proc/cpuinfo

出现vmx说明支持。

 

3 安装虚拟化软件

[root@localhost ~]# yum install -y qemu-kvmqemu-img virt-manager libvirt libvirt-python python-virtinst libvirt-clientvirt-install virt-viewer  bridge-utils


 

4 制作win7镜像的准备工作

4.1) 在centos7的/目录创建/win7

[root@localhost/]#mkdir /win7

[root@localhost/]#qemu-img create -f qcow2 -o size=20G/win7/windows7_64_20G

[root@localhost/]#chmod 777 /win7/*

4.2)把win7的iso镜像,磁盘驱动virtio-win-0.1.141_amd64.vfd和网卡驱动virtio-win-0.1.141.iso利用sftp复制到centos7系统下的/win7下。

sftp> pwd                

/root

sftp> cd /win7

sftp> pwd

/win7

sftp> lpwd

H:/OS ISO

sftp> putcn_windows_7_ultimate_with_sp1_x64_dvd_618537.iso

正在把cn_windows_7_ultimate_with_sp1_x64_dvd_618537.iso 上传到/win7/cn_windows_7_ultimate_with_sp1_x64_dvd_618537.iso

  100%3338918KB   7968KB/s 00:06:59    

sftp>

4.3) 把win7的ISO镜像改为win7.iso

4.4)在宿主主机上的/win7目录如下文件:

[root@localhost win7]# ll -a

total 4960036

drwxr-xr-x  2 root root        117 Jan  8 03:57 .

dr-xr-xr-x. 18 root root        256 Jan 8 02:31 ..

-rw-r--r--  1root root          0 Jan  8 02:38 1.txt

-rw-r--r-- 1 root root  316628992 Jan 8 03:57 virtio-win-0.1.141.iso

-rw-r--r--  1 qemu qemu    1474560 Jan  8 03:54 virtio-win-1.1.16.vfd

-rw-r--r--  1 qemu qemu 3419052032 Jan  802:46 win7.iso

-rwxrwxrwx  1 qemu qemu 1239220224 Jan  804:00 windows7_64_20G

[root@localhost win7]#


4.5) 由于宿主机是安装在esxi主机上的VM,在制作win7镜像的过程中,界面显示的问题,需要安装VNC,通过另一台windows系统远程桌面到centos7系统,安装vnc。

 检测是否安装了vnc?

[root@localhost ~]#rpm -q tigervnc tigervnc-server,如没有安装进行安装,如下命令:

[root@localhost ~]#yum install tigervnc-server -y

 创建帐号,实现访问远程桌面

[root@localhost ~]#useraddtest

[root@localhost ~]#passwd test

当一个用户尝试使用VNC访问远程桌面时,VNC守护进程就会启动来处理这个请求。这意味着你需要为每个用户创建一个独立的VNC配置文件。

CentOS依靠systemd来管理和配置系统服务。所以我们将使用systemd来为用户xmodulo配置VNC服务器。

首先让我们使用下面任意一条命令来检查VNC服务器的状态。

[root@localhost ~]# systemctl status vncserver@:.service

[root@localhost ~]# systemctl is-enabled vncserver@.service

默认的,刚安装的VNC服务并没有激活(禁用)。

现在复制一份通用的VNC服务文件来为用户test创建一个VNC服务配置。

[root@localhost ~]# cp /lib/systemd/system/vncserver@.service/etc/systemd/system/vncserver@:1.service

 

更改User及PIDFile部分:

[Service]

Type=forking

User=test

 

# Clean any existing files in /tmp/.X11-unix environment

ExecStartPre=-/usr/bin/vncserver -kill %i

ExecStart=/usr/bin/vncserver %i

PIDFile=/homt/test/.vnc/%H%i.pid

ExecStop=-/usr/bin/vncserver -kill %i

 

现在为用户test设置密码(可选)。首先切换到该用户,并运行vncserver命令。

# su - test

# vncserver

你会被提示输入用户的VNC密码。密码设置完成后,你下次需要用这个密码来访问你的远程桌面。

最后,重新加载服务来使新的VNC配置生效:

# systemctl daemon-reload

在启动时自动启动VNC服务:

# systemctl enable vncserver@:1.service

检查vnc服务正在监听的端口:

# netstat -tulpn | grep vnc


端口5901是VNC默认的客户端连接到VNC服务器使用的端口。


Windows系统,访问远程桌面


下载VNC Viewer

下载地址:http://www.realvnc/download/viewer/;下载后,直接双击exe即可,进行简单设置:



双击OK,进入了centos7的桌面。


5 制作win7镜像的过程

5.1 win7 Installation前的操作

点击新建虚机,选择安装的磁盘:


选择操作系统安装的磁盘,操作系统类型及版本:


选择内存大小,CPU的个数:


 

 

虚机的文件:


选择磁盘为virtIO,存储类型为qcow2:


 

 

 

选择网卡类型:


选择”Display Spice”为VNC Server:


 

 

 

选择”Video Cirrus”为Cirrus:


增加硬件,选择Storage,选择virtio-win-0.1.141_amd64.vfd,以便后面win7安装时安装硬盘驱动:

 

 

增加硬件,选择Storage,选择win7.iso镜像:


选择光驱启动:


 

 

 

点击“Begin Installation”:

5.2 win7 Installation后的操作

下一步:

现在安装:

接受许可,下一步:

自定义(高级)安装:

选择“加载驱动程序(L)”:


选择“浏览(B)”:

A盘为虚机启动时安装虚机的磁盘驱动,光驱为win7的镜像:

在A盘符下找到win7的硬盘驱动:

稍等片刻,识别出虚机的硬盘,下一步:


开始正常安装win7系统:跟正常安装win7一样,时间会很长,过程就不贴图了:



因为现在win7虚机的启动仍然为光盘启动,所以会出现下面的提示,可以先把虚机停掉,选择硬盘启动,或者重启2遍也可以进入操作系统,继续安装:







虚机停掉,选择硬盘启动,再启动:

输入用户名“test”,下一步:



跳过(K),下一步:


再设置日期,时间等信息:





把virtio-win-0.1.141.iso挂上光驱,安装网卡驱动:


指定virtio-win-0.1.141.iso位置,

挂上光驱,安装网卡驱动:




网卡驱动安装成功后,虚机网卡会桥街道宿主centos7.0的virbr0网卡上,并得到一个IP地址。


新虚机win7网卡有关的信息:

[root@localhost dnsmasq]# virsh list

 Id    Name                           State

----------------------------------------------------

 4     win7                           running

 

[root@localhost dnsmasq]# virsh domiflist win7

Interface  Type       Source     Model      MAC

-------------------------------------------------------

vnet0      network    default   virtio      52:54:00:64:e5:8d

 

[root@localhost dnsmasq]# brctl show

bridge name     bridgeid               STP enabled     interfaces

virbr0         8000.525400149409       yes             virbr0-nic

                                                       vnet0

[root@localhost dnsmasq]#

Vnet0使用dnsmasq提供DHCP服务,可以在宿主机中查看该进程信息:

[root@localhost dnsmasq]# ps -elf | grep dnsmasq

5 S nobody    1563     1 0  80   0 - 3901 poll_s 05:12 ?       00:00:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf--leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper

1 S root      1565  1563 0  80   0 - 3894 pipe_w 05:12 ?       00:00:00 /usr/sbin/dnsmasq--conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro--dhcp-script=/usr/libexec/libvirt_leaseshelper

0 S root     3186131529  0 80   0 - 28166 pipe_w 08:24pts/0    00:00:00 grep --color=autodnsmasq

在var/lib/libvirt/dnsmasq目录中如下文件,可以查到相应的信息:

[root@localhost dnsmasq]# pwd

/var/lib/libvirt/dnsmasq

[root@localhost dnsmasq]# ll

total 12

-rw-r--r--  1 rootroot   0 Jan 13 05:12 default.addnhosts

-rw-------. 1 root root 588 Jan 13 05:12 default.conf

-rw-r--r--  1 rootroot   0 Jan 13 05:12 default.hostsfile

-rw-r--r--  1 rootroot  80 Jan 13 07:14 virbr0.macs

-rw-r--r--  1 root root187 Jan 13 08:05 virbr0.status

[root@localhost dnsmasq]# more default.conf

##WARNING:  THIS IS ANAUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE

##OVERWRITTEN AND LOST. Changes to this configuration should be made using:

##    virsh net-edit default

## or other application using the libvirt API.

##

## dnsmasq conf file created by libvirt

strict-order

pid-file=/var/run/libvirt/network/default.pid

except-interface=lo

bind-dynamic

interface=virbr0

dhcp-range=192.168.122.2,192.168.122.254

dhcp-no-override

dhcp-authoritative

dhcp-lease-max=253

dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile

addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts

[root@localhost dnsmasq]# more virbr0.macs

[

  {

    "domain":"win7",

    "macs": [

     "52:54:00:64:e5:8d"

    ]

  }

]

[root@localhost dnsmasq]# more virbr0.status

[

  {

   "ip-address": "192.168.122.209",

   "mac-address": "52:54:00:64:e5:8d",

   "hostname": "test-PC",

   "client-id": "01:52:54:00:64:e5:8d",

   "expiry-time": 1515852307

  }

]

[root@localhost dnsmasq]#

以上工作完成后,就可以将windows7_64_20G复制到openstack的镜像中了,有没有.qcow2的后缀都是qcow2格式,你可以在命令行下使用file windows7_64_40G进行验证:

[root@localhost win7]# filewindows7_64_20G

windows7_64_20G: QEMU QCOWImage (v3), 21474836480 bytes

[root@localhost win7]#

加个.qcow2的后缀只是为了方便人类识别。

引用网上的一位网友“Michael_Tong”的话:“愚蠢的人类”,再加一句话:人类会越来越成为计算机的奴隶!!!,可悲!!!。

5.3 win7隐藏的Administrator用户显示出来

在开始→运行中输入:lusrmgr.msc 点击 确定 或回车(Enter键)打开本地用户和组;

双击Administrator账户,去掉 账户已禁用 前的选中对勾→确定;

点击开始→关机右边的小三角 →切换用户。

5.4 COPY win7镜像到Openstack环境下,生成实例

可以把镜像压缩。


 







 












更多推荐

Centos7制作Openstack下win7 镜像

本文发布于:2023-04-14 15:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/65639beccd0a3200c015b66fee833de8.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:镜像   Openstack

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 76349文章数
  • 14阅读数
  • 0评论数