Xen虚拟机磁盘镜像模板制作(一)—Windows Server 2008(2012)
这段时间一直在研究如何制作一个适合Xen虚拟化的Windows Server 2008(2012)磁盘镜像,中间虽然遇到了一些阻挠,不过最终还是顺利解决,成功制作出了Xen Windows Server 2008(2012) 磁盘镜像模板。这里记录下整个制作过程:
1、首先要确保服务器的VT已经打开,可以通过如下命令来查看:
[root@localhost ~]# cat /proc/cpuinfo | egrep '(vmx|svm)'
如果有输出,则说明该服务器的VT已经打开。
2、创建一个将要用来安装Windows Server 2008(2012)系统的LV,命令如下:
[root@localhost ~]# lvcreate -L 15G -n windows vg0
Logical volume "windows" created
参数说明:
1)-L:指定LV的大小。这里设置为15G,是因为Windows Server 2008(2012)系统本身安装完后,占用系统盘较大,大约在9--10G;另外官方推荐系统盘大小要在13G以上
2)vg0:这里是我测试创建的vg
3、查看已经成功创建的系统LV:
[root@localhost ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
windows vg0 -wi-a- .00G
[root@localhost ~]# ll /dev/vg0/windows
lrwxrwxrwx root root Jun : /dev/vg0/windows -> /dev/mapper/vg0-windows
4、系统LV 创建好后,开始准备Xen虚拟机的配置文件:
kernel = "/usr/lib/xen/boot/hvmloader"
builder='hvm'
memory =
name = "windows"
vif = [ 'bridge=eth0' ]
disk = [ 'phy:/dev/vg0/windows,hda,w','file:/root/cn_windows_server_2008_r2_standard_enterprise_datacenter_and_web_with_sp1_x64_dvd_617598.iso,hdc:cdrom,r' ]
vcpus =
on_reboot = 'restart'
on_crash = 'restart'
boot = 'd'
sdl =
vnc =
vnclisten = '0.0.0.0'
vncdisplay =
stdvga =
serial = 'pty'
usbdevice = 'tablet'
localtime =
注意:
1)这里使用的是全虚拟化方式安装Windows Server虚拟机,后面会安装半虚拟化驱动qplpv driver
2)要设置虚拟机从CDROM启动
5、创建并启动Windows Server虚拟机,命令如下:
[root@localhost ~]# xm create /root/windows.cfg
Using config file "/root/windows.cfg".
Started domain windows (id=)
6、此时Windows Server虚拟机已经启动,进入到系统安装界面,下面就是按部就班地安装系统;我们通过VNC客户端连接到虚拟机上,如下所示:

7、系统安装到下面这一步时:

这里我们需要事先手动对整块磁盘进行分区并格式化,因为如果我们采用了系统默认的分区格式化方式,系统会帮我们创建一个100M的隐藏分区,后期我们在导出系统文件时会比较麻烦。
这里同时按住 Shift + F10,弹出命令提示符界面,执行如下命令进行磁盘分区并格式化:

执行命令后,关闭命令提示符,点击"刷新",发现此时磁盘分区已经创建好了,而且没有那100M的隐藏分区,如下图:

8、后面就是系统安装过程了:

9、系统安装完成后,关闭虚拟机,修改Xen虚拟机配置文件:
kernel = "/usr/lib/xen/boot/hvmloader"
builder='hvm'
memory =
name = "windows"
vif = [ 'bridge=eth0' ]
disk = [ 'phy:/dev/vg0/windows,hda,w','file:/root/xen-windows-driver.iso,hdc:cdrom,r' ]
vcpus =
on_reboot = 'restart'
on_crash = 'restart'
boot = 'c'
sdl =
vnc =
vnclisten = '0.0.0.0'
vncdisplay =
stdvga =
serial = 'pty'
usbdevice = 'tablet'
localtime =
注意:
1)设置系统从硬盘启动
2)修改CDROM为xen-windows-driver.iso
PS:这里的xen-windows-driver.iso是本人通过 mkisofs 命令制作的,里面仅仅包含了qplpv drvier及agent,你同样可以制作你自己需要的iso文件
10、下面就是根据需要修改一些Windows Server系统配置的工作,具体如下:
1)关闭防火墙
2)开启远程桌面
3)设置新磁盘自动联机,具体命令如下:

4)安装半虚拟化驱动qplpv driver

安装完重启后,我们发现"设备管理器"里的驱动变为Xen的了

11、至此,系统配置修改已经完成了,下面关闭虚拟机,备份磁盘MBR主引导扇区,命令如下:
[root@localhost ~]# dd if=/dev/vg0/windows of=windows_mbr bs= count=
+ records in
+ records out
bytes ( B) copied, 0.010009 seconds, 51.2 kB/s
[root@localhost ~]# ll windows_mbr
-rw-r--r-- 1 root root 512 Jun 2 15:49 windows_mbr
12、创建磁盘分区映射,将所有分区映射到/dev/mapper下:
[root@localhost ~]# kpartx -av /dev/vg0/windows
add map windows1 : linear /dev/vg0/windows
[root@localhost ~]# ll /dev/mapper/
total
crw------- root root , May : control
brw-rw---- root disk , Jun : vg0-windows
brw-rw---- root disk , Jun : windows1
[root@localhost ~]#
因为前面我们安装系统时只创建了一个分区,因此这里就只有一个windows分区,即windows1
13、mount windows分区到mnt下:
[root@localhost ~]# mount -t ntfs-3g /dev/mapper/windows1 /mnt/
[root@localhost ~]# ll /mnt/
total
drwxrwxrwx root root Jun : Boot
-rwxrwxrwx root root Nov bootmgr
-rwxrwxrwx root root Jun : BOOTSECT.BAK
lrwxrwxrwx root root Jul Documents and Settings -> /mnt//Users
-rwxrwxrwx root root Jun : pagefile.sys
drwxrwxrwx root root Jul PerfLogs
drwxrwxrwx root root Jun : ProgramData
drwxrwxrwx root root Jun : Program Files
drwxrwxrwx root root Jun : Program Files (x86)
drwxrwxrwx root root Jun : Recovery
drwxrwxrwx root root Jul $Recycle.Bin
drwxrwxrwx root root Jun : System Volume Information
drwxrwxrwx root root Jun : Users
drwxrwxrwx root root Jun : Windows
[root@localhost ~]#
因为windows文件系统是NTFS格式的,所以这里类型要设置为ntfs-3g
14、删除文件 pagefile.sys:
[root@localhost ~]# rm -f /mnt/pagefile.sys
[root@localhost ~]# ll /mnt/
total
drwxrwxrwx root root Jun : Boot
-rwxrwxrwx root root Nov bootmgr
-rwxrwxrwx root root Jun : BOOTSECT.BAK
lrwxrwxrwx root root Jul Documents and Settings -> /mnt//Users
drwxrwxrwx root root Jul PerfLogs
drwxrwxrwx root root Jun : ProgramData
drwxrwxrwx root root Jun : Program Files
drwxrwxrwx root root Jun : Program Files (x86)
drwxrwxrwx root root Jun : Recovery
drwxrwxrwx root root Jul $Recycle.Bin
drwxrwxrwx root root Jun : System Volume Information
drwxrwxrwx root root Jun : Users
drwxrwxrwx root root Jun : Windows
[root@localhost ~]#
15、unmount windows分区:
[root@localhost ~]# umount /mnt/
[root@localhost ~]# ll /mnt/
total
[root@localhost ~]#
16、打包并压缩windows1分区里的系统文件:
[root@localhost ~]# ntfsclone --save-image --output - /dev/mapper/windows1 | gzip -c > windows_img
ntfsclone v1.13.1 (libntfs ::)
NTFS volume version: 3.1
Cluster size : bytes
Current volume size: bytes ( MB)
Current device size: bytes ( MB)
Scanning volume ...
100.00 percent completed
Accounting clusters ...
Space in use : MB (45.2%)
Saving NTFS to image ...
100.00 percent completed
Syncing ...
[root@localhost ~]# ll windows_img
-rw-r--r-- 1 root root 3073945978 Jun 2 16:14 windows_img
17、删除磁盘分区映射:
[root@localhost ~]# kpartx -d /dev/vg0/windows
[root@localhost ~]# ll /dev/mapper/
total
crw------- root root , May : control
brw-rw---- root disk , Jun : vg0-windows
[root@localhost ~]#
18、至此,我们需要的Xen Windows Server磁盘镜像模板就制作好了,下面两个文件就是我们需要的:
[root@localhost ~]# ll windows_*
-rw-r--r-- 1 root root 3073945978 Jun 2 16:14 windows_img
-rw-r--r-- 1 root root 512 Jun 2 15:49 windows_mbr
[root@localhost ~]#
PS:这里虽然是Windows Server 2008示例说明,但2012过程同上。
Xen虚拟机磁盘镜像模板制作(一)—Windows Server 2008(2012)的更多相关文章
- Xen虚拟机磁盘镜像模板制作(二)—Windows Server 2008(2012)
在<Xen虚拟机磁盘镜像模板制作(一)—Windows Server 2008(2012)>一文中,我们已经成功制作出了Windows Server磁盘镜像.下面我们说明下如何通过它来生成 ...
- Xen虚拟机磁盘镜像模板制作(四)—CentOS 7
在<Xen虚拟机磁盘镜像模板制作(三)—CentOS 7>一文中,我们已经成功制作出了 CentOS7 磁盘镜像.下面我们说明下如何通过它来生成目标虚拟机,同时测试下之前制作好的虚拟机磁盘 ...
- Xen虚拟机磁盘镜像模板制作(三)—CentOS 7
这里整理下制作Xen CentOS 7磁盘镜像模版的流程: 1.创建一个将要用来安装CentOS 7系统的LV,命令如下: [root@localhost ~]# lvcreate -L 5G -n ...
- 阿里云服务器Windows Server 2008/2012部署Office Web Server 2013
以前成功将Office Web Server 2013部署在了本地服务器上,此次是将Office Web Server 2013部署在阿里云服务器Windows Server 2008和2012上,中 ...
- 【定时任务|开机启动】Windows Server 2008/2012 计划任务配置(任务计划程序)每分钟执行BAT
打开计划任务快捷方式(在 “管理工具”内): C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools\Tas ...
- Windows Server 2008/2012 计划任务配置执行bat
首先Windows Server 2008不同于其他服务器操作系统和Windows Server 2003有着很大的区别,计划任务的名称是“任务计划程序”不在控制面板里,而是在“管理工具”里.由于服务 ...
- 配置Windows Server 2008/2012/2016允许2个用户同时远程桌面
Windows Server 系列服务器默认情况下只能支持一个用户远程,如果第二个人远程上去之后会直接把前面一个登录用户踢掉.在日常工作中如果有多个人需要同时远程过去工作,会很不方面. 网上很多教程讲 ...
- windows server 2008/2012安装PostgreSQL过程及问题总结
今天第一次接触在Windows Server2008/2012 下安装PostgreSQL,遇到的问题总结如下: 1.首先,在安装的时候,我更改安装目录改为自定义的E盘,安装时报错:libintl.d ...
- windows server 2008/2012 无法安装AD域解决方法记录
安装活动目录之前需要一些准备工作和前提条件的. 有管理员的权限 至少有一个足够大的NTFS文件系统的分区或动态卷 需要DNS服务配合,因此需要安装DNS服务 最好使用dcpromo命令来进行安装 最终 ...
随机推荐
- php solr 扩展
安装php的solr扩展 下载地址: http://pecl.php.net/get/solr windows下载地址: http://downloads.php.net/pierre/php_sol ...
- Oozie简介
在Hadoop中执行的任务有时候需要把多个Map/Reduce作业连接到一起,这样才能够达到目的.[1]在Hadoop生态圈中,有一种相对比较新的组件叫做Oozie[2],它让我们可以把多个Map/R ...
- python处理url中的中文编码,以及其他编码问题
1.python中的urlencode与urldecode 2.各种编码转换在线工具 3.python用于url解码和中文解析的小脚本(python url decoder) 4.如何只对url中的中 ...
- HDOJ 1754 I Hate It 线段树 第二题
I Hate It Problem Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少.这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就 ...
- jQuery初步
1.jQuery开发步骤 jQuery是第三方开源组织基于js写的一款跨主流浏览器的实用库. (1)引用第三方js库文件,<script type="text/javascript&q ...
- 【C语言学习】-01 C基础
本文目录: 0.进制转换 1.C数据类型 2.常量变量 3.运算符 4.表达式 5.格式化输入输出 回到顶部 0.进制转换 在计算机中存储的数据,主要是以二进制形式存在,而我们生活中主要使用的有十进制 ...
- [流媒体]live555简介(转)
live555简介 Live555 是一个为流媒体提供解决方案的跨平台的C++开源项目,它实现了对标准流媒体传输协议如RTP/RTCP.RTSP.SIP等的支持.Live555实现 了对多种音视频编码 ...
- Apache虚拟主机(三)
一.启用 httpd-vhosts.conf 在httpd.conf文件中启用 在文件中搜索:Virtual hosts #Virtual hosts虚拟主机 Include conf/extra/h ...
- POJ 2752 - Seek the Name, Seek the Fame (KMP)
题意:给一个字符串s,问s的某个前缀与后缀相同的情况时,长度是多少. 此题使用KMP的next数组解决. next数组中,j=next[i],next[i]表示S[0...i-1]的某个后缀(字符串S ...
- HDU 3333 - Turing Tree (树状数组+离线处理+哈希+贪心)
题意:给一个数组,每次查询输出区间内不重复数字的和. 这是3xian教主的题. 用前缀和的思想可以轻易求得区间的和,但是对于重复数字这点很难处理.在线很难下手,考虑离线处理. 将所有查询区间从右端点由 ...