这段时间一直在研究如何制作一个适合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)的更多相关文章

  1. Xen虚拟机磁盘镜像模板制作(二)—Windows Server 2008(2012)

    在<Xen虚拟机磁盘镜像模板制作(一)—Windows Server 2008(2012)>一文中,我们已经成功制作出了Windows Server磁盘镜像.下面我们说明下如何通过它来生成 ...

  2. Xen虚拟机磁盘镜像模板制作(四)—CentOS 7

    在<Xen虚拟机磁盘镜像模板制作(三)—CentOS 7>一文中,我们已经成功制作出了 CentOS7 磁盘镜像.下面我们说明下如何通过它来生成目标虚拟机,同时测试下之前制作好的虚拟机磁盘 ...

  3. Xen虚拟机磁盘镜像模板制作(三)—CentOS 7

    这里整理下制作Xen CentOS 7磁盘镜像模版的流程: 1.创建一个将要用来安装CentOS 7系统的LV,命令如下: [root@localhost ~]# lvcreate -L 5G -n ...

  4. 阿里云服务器Windows Server 2008/2012部署Office Web Server 2013

    以前成功将Office Web Server 2013部署在了本地服务器上,此次是将Office Web Server 2013部署在阿里云服务器Windows Server 2008和2012上,中 ...

  5. 【定时任务|开机启动】Windows Server 2008/2012 计划任务配置(任务计划程序)每分钟执行BAT

    打开计划任务快捷方式(在 “管理工具”内): C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools\Tas ...

  6. Windows Server 2008/2012 计划任务配置执行bat

    首先Windows Server 2008不同于其他服务器操作系统和Windows Server 2003有着很大的区别,计划任务的名称是“任务计划程序”不在控制面板里,而是在“管理工具”里.由于服务 ...

  7. 配置Windows Server 2008/2012/2016允许2个用户同时远程桌面

    Windows Server 系列服务器默认情况下只能支持一个用户远程,如果第二个人远程上去之后会直接把前面一个登录用户踢掉.在日常工作中如果有多个人需要同时远程过去工作,会很不方面. 网上很多教程讲 ...

  8. windows server 2008/2012安装PostgreSQL过程及问题总结

    今天第一次接触在Windows Server2008/2012 下安装PostgreSQL,遇到的问题总结如下: 1.首先,在安装的时候,我更改安装目录改为自定义的E盘,安装时报错:libintl.d ...

  9. windows server 2008/2012 无法安装AD域解决方法记录

    安装活动目录之前需要一些准备工作和前提条件的. 有管理员的权限 至少有一个足够大的NTFS文件系统的分区或动态卷 需要DNS服务配合,因此需要安装DNS服务 最好使用dcpromo命令来进行安装 最终 ...

随机推荐

  1. CentOS命令登录MySQL时,报错ERROR 1045 (28000):

    CentOS命令登录MySQL时,报错ERROR 1045 (28000): Access denied for user root@localhost (using password: NO)错误解 ...

  2. 修改weblogic部署的应用名称

    通过weblogic管理后台console进行发布本地项目的时候,它会默认以WEB-INF的上一级目录作为访问路径,如,假如你的项目WEB-INF目录的上一层是WebRoot,那么发布后,访问的路径默 ...

  3. AudioManager音频管理器

    AudioManager音频管理器提供了如下几种常用方法来控制手机音频: 1.adjustStreamVolume(int StreamType,int direction,int flgs):调整手 ...

  4. plsql快速选中一行的快捷键

    实际工作中,经常用到pl/sql,在sql window中,经常性的用到选中一行然后按F8执行这条sql语句.用鼠标选中一行不是特别方便.用快捷键就快多了. 1.使用home键(不是windows键奥 ...

  5. 转: JSP中include指令和include动作的区别

    include指令是编译阶段的指令,即include所包含的文件的内容是编译的时候插入到JSP文件中,JSP引擎在判断JSP页面未被修改,否则视为已被修改.由于被包含的文件是在编译时才插入的,因此如果 ...

  6. SG函数 模板

    int get_SG(int x) { ) return SG[x]; ]={}; ;i<=n;i++) ) v[get_SG(x-s[i])]=; int i; ;v[i];i++); SG[ ...

  7. winform的comboBox使鼠标滑轮修改值失效

    目标: winform窗体很多combobox下拉框,当他们其中的一个获得焦点的时候,如果滚动鼠标就会改变下拉框的值,要实现让鼠标滚轮不对下拉框的值造成影响 如下代码直接拷贝粘贴,不用修改 方法一: ...

  8. uboot启动 及命令分析(3)

    u-boot命令 先贴一个重要结构,位于uboot/include/command.h,这个结构代表每个uboot命令 struct cmd_tbl_s { char     *name;   /* ...

  9. GET /hello/fred/0926xxx572

    GET /hello/fred/0926xxx572 app.get('/hello/:name/:tel', function(req, res) { console.log(req.params. ...

  10. ubuntu 防火墙 添加策略 解决mysql远程访问问题

    ubuntu 的iptables 文件不在 init.d中 不能 service iptables restart 只修改 /etc/iptables 文件也不管用 sudo iptables -L ...