用qemu搭建CentOS 6 for colinux虚拟系统

 

一、安装的软硬件环境

操作系统: Windows XP SP3

        硬件环境: CPU  AMD 速龙AthlonII X3 445 (3.1GHz/AM3/3*512KB二缓/45纳米)

                   内存 Corsair 海盗船 CMX4GX3M2A1600C9 DDR3 1600 4G(2G*2)

                   硬盘 Seagate 希捷 ST31000528AS SATAII台式机硬盘(1TB/7200转/32M)

                   主板 Asrock 华擎 870 Extreme3 主板 (AMD 870 芯片组/AM3 )

                   显卡 ZOTAC 索泰 GTX460-1GD5 毁灭者(GTX 460芯片组/1024M/GDDR5)

二、下载colinux软件

    colinux最新本是colinux-0.7.9.exe版本,可从官方网址(www.colinux.com)处下载。

三、安装colinux软件

    首先双击上述下载的colinux-0.7.9.exe执行文件来运行安装,运行后如下图:

   

windows 使用qemu打开qcow2 qemu for windows_CentOS

    点击【Next】按钮至如下图:

    

windows 使用qemu打开qcow2 qemu for windows_linux_02

    点击【I Agree】按钮至如下图:

    

windows 使用qemu打开qcow2 qemu for windows_centos_03

    由于官方未提供CentOS 6.0的Root Filesystem p_w_picpath下载,因此去掉上图中的【Root Filesystem p_w_picpath Download】选项,并继续点击【Next】按钮至如下图:

    

windows 使用qemu打开qcow2 qemu for windows_运维_04

    在上图中填入安装路径,偶在这里填了D:\colinux\,填写完后继续点击【Next】至如下图:

    

windows 使用qemu打开qcow2 qemu for windows_CentOS_05

    上图提示你若需要安装WinPCAP时,可到其官方网站下载来安装;由于后面偶选择使用TAP Win32虚拟网卡,这里就选择不安装WinPCAP,因此不用去下载了,那么就继续点击【Next】至如下图:

    

windows 使用qemu打开qcow2 qemu for windows_centos_06

    上图就是开始执行复制文件、安装驱动等的colinux具体安装进度界面,直到需要安装TAP Win32虚拟网卡驱动时,会弹出如下图:

    

windows 使用qemu打开qcow2 qemu for windows_linux_07

上图中点击【仍然继续】按钮来执行安装TAP Win32虚拟网卡驱动,该驱动安装成功后就会在Windows的网络连接中出现一个网卡,如下图(图中“本地连接2”就是新出现的TAP Win32虚拟网卡):

windows 使用qemu打开qcow2 qemu for windows_linux_08

     等colinux具体安装进度界面进度到100%后就会至如下图:

    

windows 使用qemu打开qcow2 qemu for windows_运维_09

 

    点击上图【Finish】按钮来结束colinux的安装。至此colinux-0.7.9版本就被偶安装在D:\colinux\目录下了,如下图:

windows 使用qemu打开qcow2 qemu for windows_运维_10

四、制作CentOS 6.0的colinux能使用的Root Filesystem Image

    由于CentOS的光盘不支持直接用colinux启动来安装,因此需要借助Qemu虚拟机先安装CentOS 6.0,然后把Qemu的Image格式转化成colinux的Image格式。

    Qemu的官方网站是www.qemu.org,官网中只支持Linux版本,而Windows下Qemu版本需要从Precompiled Windows versionsQemu Manager for Windows (and Wine) 寻找,Qemu for Windows的最新版本为qemu-0.14.1,很遗憾的是其不再支持KQEMU(QEMU在Windows下的加速器),而最后支持KQEMU的Qemu for Windows版本可在qemu-0.11.1 for windows Support KQEMU下载,也可从Qemu Manage(Windows下带界面配置的Qemu管理器)网站下载Qemu Manager v7.0 (April 2010) with Qemu 0.11.1 and KQEMU Support

    1. 准备工作:先下载CentOS 6.0 ISO(建议国内从163的镜像下载速度快)文件至D:\CentOS6_DVD\CentOS_6.0_Final.iso; 偶这里只用带命令行的qemu-0.11.1 for windows Support KQEMU,下载后解压至D:\Qemu\目录下;以及KQEMU,下载后解压至D:\Qemu\Kqemu\目录下;进入至D:\Qemu\Kqemu\目录,双击或右键点击文件kqemu.inf(注意Windows Vista\Windows 7下用kqemu_win7.inf文件)选择【安装】菜单来安装好kqemu服务。

    2. 制作在Qemu上安装CentOS用的初始Image文件(7GB的主磁盘空间和1GB的SWAP空间文件),其创建在D:\Qemu\CentOS6\目录下,用如下DOS命令来创建:
        D:\Qemu>md CentOS6
        D:\Qemu>fsutil file createnew d:\qemu\CentOS6\qemu_centos6_7gb 7517241344
        D:\Qemu>fsutil file createnew d:\qemu\CentOS6\swap_1gb 1073741824

    3. 启动Qemu来安装CentOS6,进入D:\Qemu\ qemu-0.11.1-windows目录用如下DOS命令来启动:
        D:\Qemu\qemu-0.11.1-windows>net start kqemu
        D:\Qemu\qemu-0.11.1-windows>qemu.exe -L . -m 1024 -kernel-kqemu -hda d:\qemu\CentOS6\qemu_centos6_7gb -hdb d:\qemu\CentOS6\swap_1gb -cdrom d:\centos6_dvd\CentOS_6.0_Final.iso -boot order=dc

    启动后如下图:

windows 使用qemu打开qcow2 qemu for windows_操作系统_11

 

Install or upgrade an existing system】后至如下图:

windows 使用qemu打开qcow2 qemu for windows_linux_12

 

    等待直到出现如下图:

windows 使用qemu打开qcow2 qemu for windows_linux_13

 

Skip】至如下3图:

windows 使用qemu打开qcow2 qemu for windows_操作系统_14

windows 使用qemu打开qcow2 qemu for windows_CentOS_15

windows 使用qemu打开qcow2 qemu for windows_centos_16

Next】按钮至如下图:

windows 使用qemu打开qcow2 qemu for windows_centos_17

 

”Chiness(Simplified)(中文(简体))”,并点击【Next】按钮至如下图:

windows 使用qemu打开qcow2 qemu for windows_运维_18

 

    键盘格式默认选择“美国英语式”,并点击【下一步】按钮至如下图:

windows 使用qemu打开qcow2 qemu for windows_运维_19

    默认选择“基本存储设备”,并点击【下一步】按钮至如下图:

windows 使用qemu打开qcow2 qemu for windows_CentOS_20

 

jhuix.centos6”,然后点击【下一步】至如下图:


UTC时间”,接着点击【下一步】按钮至如下图:

windows 使用qemu打开qcow2 qemu for windows_运维_21

 

123456)后,点击【下一步】结果出来一提示框:

windows 使用qemu打开qcow2 qemu for windows_操作系统_22

    选择点击了【无论如何都使用】至如下图: 

windows 使用qemu打开qcow2 qemu for windows_linux_23

 

Linux系统”,及勾选上“查看并修改分区布局”,接着点击【下一步】按钮至如下图:

windows 使用qemu打开qcow2 qemu for windows_运维_24

7GB的分区为引导装载程序标志,接着点击【下一步】继续至如下图:

windows 使用qemu打开qcow2 qemu for windows_linux_25

    点击【重设】按钮弹出一提示框:

windows 使用qemu打开qcow2 qemu for windows_操作系统_26

 

    选择点击【是】后出现如下图:

windows 使用qemu打开qcow2 qemu for windows_centos_27

 

”sda1”选项,并点击【创建】按钮弹出对话框:

windows 使用qemu打开qcow2 qemu for windows_linux_28

 

    选择“标准分区”,及点击【生成】弹出一对话框:

windows 使用qemu打开qcow2 qemu for windows_运维_29

 

/”、文件系统类型为“ext4”、允许的驱动器只选择“sda”、其它大小选项选择“使用全部可用空间”,然后点击【确定】至如下图:

windows 使用qemu打开qcow2 qemu for windows_运维_30

 

sdb1设置为swap,然后点击【下一步】至如下图:

windows 使用qemu打开qcow2 qemu for windows_运维_31

 

    点击【将修改写入磁盘】会格式化分区,格式化完成后至如下图:

windows 使用qemu打开qcow2 qemu for windows_linux_32

/dev/sda中安装引导装载程序”及引导装载程序操作系统列表中的默认标志,然后点击【下一步】至如下图:

windows 使用qemu打开qcow2 qemu for windows_操作系统_33

 

”Minimal”进行最小化安装,其他有需要的组件安装好后并切换至colinux平台下时再手工用yum来安装,点击【下一步】按钮至如下图:

windows 使用qemu打开qcow2 qemu for windows_操作系统_34

 

    依赖关系检查完后自动出现启动安装过程如下图:

windows 使用qemu打开qcow2 qemu for windows_操作系统_35

 

100%后自动进行软件包的复制安装过程,如下图:

windows 使用qemu打开qcow2 qemu for windows_centos_36

 

100%了,并且自动进行引导装载程序的安装,如下图:

windows 使用qemu打开qcow2 qemu for windows_操作系统_37

    引导装载程序安装完成后,自动出现如下图:

windows 使用qemu打开qcow2 qemu for windows_centos_38

CentOS 6在Qemu虚拟机中安装成功,可喜可贺,点击【重新引导】来启动CentOS 。Qemu启动CentOS过程如下图:

windows 使用qemu打开qcow2 qemu for windows_操作系统_39

windows 使用qemu打开qcow2 qemu for windows_运维_40

windows 使用qemu打开qcow2 qemu for windows_centos_41

root和密码123456后,进入CentOS控制端了,用shutdown –h now关闭centos并自动退出qemu虚拟机。

    4.  Qemu的Image格式转换成colinux的Image格式,回到Windows的CMD模式下,进入 D:\Qemu\CentOS6\目录下键入如下DOS命令:
        D:\Qemu\CentOS6>dd if=qemu_centos6_7gb of=D:\colinux\Images\centos_7gb bs=512 skip=2048

     小技巧:
        a. 在windows下没有dd命令下呀?
           微软是不提供这命令的,但是我们可以下载一个
UnxUtils装上就会有了。
        b. 为何这样转换就是colinux的Image格式呢?而且在CentOS 5.X版本时,这种方式转换时skip参数为63的,CentOS6怎么是2048了呢?
           这是由于引导程序在CentOS 5.X版本中占用63个磁盘扇区,而在CentOS 6版本中占用了2048个磁盘扇区;而colinux的Image格式是不带引导分区的,因此需要用dd命令把引导程序占用的磁盘区域给剔除掉。提示:至于如何获取引导分区占用几个磁盘扇区可以用命令来获取:file <p_w_picpath文件名>

五、启动centos 6 的colinux虚拟系统

    1.  复制D:\qemu\CentOS6\swap_1gb文件至D:\colinux\Images目录下。

2.  在D:\colinux目录下复制example.conf为centos6.conf,并对centos6.conf修改如下:
#
 # This is an example for a configuration file that can
 # be passed to colinux-daemon in this manner:
 #
 #    colinux-daemon @example.conf
 #
 # Note that you can still prepend or append configuration and 
 # boot parameters before and after '@', or you can use more 
 # that one '@ to load several settings one after another.
 # 
 #    colinux-daemon @example.conf @overrider.conf mem=32
 #
 # Full list of config params is listed in colinux-daemon.txt.# The default kernel
 kernel=vmlinux# File contains the root file system.
 # Download and extract preconfigured file from SF "Images for 2.6".
cobd0="D:\colinux\Images\centos6_7gb"# Swap device, should be an empty file with 128..512MB.
cobd1="D:\colinux\Images\swap_1gb"#CD-ROM
 cobd2="D:\centos6_dvd\CentOS_6.0_Final.iso"# Tell kernel the name of root device (mostly /dev/cobd0,
 # /dev/cobd/0 on Gentoo)
 # This parameter will be forward to Linux kernel.
root=/dev/cobd0 rootfstype=ext4 fastboot 3# Additional kernel parameters (ro = rootfs mount read only)
#ro# Initrd installs modules into the root file system.
 # Need only on first boot.
 initrd=initrd.gz# Maximal memory for linux guest
 mem=1024# Select console size, default is 80x25
 #cocon=120x40# Slirp for internet connection (outgoing)
 # Inside running coLinux configure eth0 with this static settings:
 # ipaddress 10.0.2.15   broadcast  10.0.2.255   netmask 255.255.255.0
 # gateway   10.0.2.2    nameserver 10.0.2.3
eth0=slirp# Tuntap as private network between guest and host on second linux device
eth1=tuntap# Setup for serial device
 #ttys0=COM1,"BAUD=115200 PARITY=n DATA=8 STOP=1 dtr=on rts=on"# Run an application on colinux start (Sample Xming, a Xserver)
 #exec0=C:\Programs\Xming\Xming.exe,":0 -clipboard -multiwindow -ac"

    3.  在D:\colinux\目录下生成生成一centos6.bat,内容如下:
         colinux-daemon.exe @centos6.conf
    4.  运行centos6.bat,出现如下图:

windows 使用qemu打开qcow2 qemu for windows_操作系统_42

windows 使用qemu打开qcow2 qemu for windows_centos_43

    至此在colinux下成功运行了centos6系统,但是这时运行的centos6系统是最小化安装的系统(没有网络、没有X11图形系统等),离可用的开发环境还缺各种系统配置(比如网络配置等)及很多软件包的安装。这会在以后的几篇中着重说明如何进行一些开发环境所需的系统配置及软件包的安装。

     由于在写第三篇文章时CentOS 6.1正式发布了,因此就又直接做了CentOS 6.1的colinux下的p_w_picpath文件并上传至网盘中分享,见下面的附件链接:

  附件:CentOS 6.1 for colinux的Image文件(已完成网络设置并安装了基础的gnome桌面、vncserver等,大小2GB)下载地址

转载于:https://blog.51cto.com/jhuix/729217