免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 10197 | 回复: 6
打印 上一主题 下一主题

小实验: 使用KVM虚拟机,安装一个windows系统 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-09-02 20:00 |只看该作者 |倒序浏览
XXX : 文档说必须在有VT(即VMX)的Intel CPU或者有SVM(即Secure Virtual Machine,也称作AMD-V)的
          AMD CPU上安装。我在Turion 64 X2上安装,没问题。
          探测AMD和Intel CPU是否支持VT或SVM,可以参考内核中kvm的has_svm()和cpu_has_kvm_support()
          函数。
   
    1. 保证内核版本在2.6.20或更新,去www.kernel.org查看你的内核的发布时间,再到:
   
       http://sourceforge.net/project/showfiles.php?group_id=180599

       下载一个发布时间稍晚于你的内核的 kvm-<release>.tar.gz

       Note: linux内核的include/linux/kvm.h中定义了一个KVM_API_VERSION宏,例如2.6.22中它是12,你
       下载的kvm-<release>.tar.gz中,user/kvmctl.c中定义了一EXPECTED_KVM_API_VERSION,这个宏的值
       必须和你用的内核匹配。 不过这步会在configure时检查,不用担心。

       # tar zvxf kvm-<release>.tar.gz -C /usr/local/
       # cd /usr/local/kvm-<release>/
   
    2. 编译之前,注意。(这步不做也可以,注意指定步骤3中的--kerneldir参数即可)
   
       KVM configure时会错误的把 /lib/modules/`uname -r`/build 认为是源代码所在
       目录(事实上/lib/modules/`uname -r`/source才是源代码目录,只有编译内核时没
       有用O=<dir>指定输出目录,这二者才是相同的)。 因此,需要更改一下,使build
       这个符号链接跟source指向的一样。

       # cd /lib/modules/2.6.22/
       # unlink build
       # ln -sf `readlink source` build

       注意做完<3>之后还要把build这个链接给改回来。


       或者不改也可以,注意在<3>中configure时的参数。

    3. configure,make,make install

       # cd /usr/local/kvm-<release>/
       # ./configure --prefix=/usr/local/kvm --with-patched-kernel
           //如果没做<2>,就加上--kerneldir=/lib/modules/`uname -r`/source
       # make
       # make install
   
    4. 加载模块

       # modprobe kvm-amd //或者modprobe kvm-intel,视你的CPU而定

   
    5. 创建虚拟磁盘

       # /usr/local/kvm/bin/qemu-img create -f qcow vdisk.img 5G
   
    6. 从ISO引导

       # /usr/local/kvm/bin/qemu-system-x86_64 -hda vdisk.img -cdrom /root/windows2000.iso -boot d -m 384
       -m 384是指定384M的内存。如果机器内存不足1G,建议用192或128。
       如果是Intel CPU,把"qemu-system-x86_64"改成"qemu"。
   
    7. 安装完毕后,启动虚拟机。

       # /usr/local/kvm/bin/qemu-system-x86_64 vdisk.img -m 384

论坛徽章:
0
2 [报告]
发表于 2007-11-02 16:38 |只看该作者
顶一下,不会跟正在用的xen冲突吧?

论坛徽章:
0
3 [报告]
发表于 2007-11-05 17:40 |只看该作者
gcc要加--disable-gcc-check参数,modprobe kvm-amd 或者modprobe kvm-intel 出错,
[root@xen001 ~]# modprobe kvm-amd
FATAL: Module kvm_amd not found.
[root@xen001 ~]# modprobe kvm-intel
FATAL: Module kvm_intel not found.
用./configure --disable-gcc-check后正常加载kvm模块,
正在安装叉屁,
我的机器是intel的cpu, 但kvn的bin里只有qemu-system-x86_64,没有
qemu。
安装比xen简单多了,还没装完发现又出来个lguest虚拟机软件,真晕

论坛徽章:
0
4 [报告]
发表于 2007-11-06 10:48 |只看该作者
网卡默认工作在NAT模式,不爽,感觉没xen和vmware方便,更多信息见
http://kvm.qumranet.com/kvmwiki/HOWTO

Getting KVM to run on your machine

目录

   1. Getting KVM to run on your machine
         1. Prerequisites
         2. Unpacking and configuring kvm components
         3. Creating a disk image for the guest
         4. Installing a guest operating system
         5. Running the newly-installed guest

Prerequisites

You will need (see download section):

    *

      kvm-release.tar.gz
    * A VT capable Intel processor, or an SVM capable AMD processor
    * qemu prerequisites:
          o

            gcc 3.x
          o

            zlib libraries and headers
          o

            SDL libraries and headers
          o

            alsa libraries and headers (optional alsa support: disabled by default but can be enabled with --enable-alsa)
          o

            gnutls libraries and headers (optional VNC TLS support: enabled by default but can be disabled with --disable-vnc-tls)
          o kernel headers (on Fedora, the kernel-devel package)

On a debian etch system you can install the prerequisites with:

  apt-get install gcc-3.4 libsdl1.2-dev zlib1g-dev libasound2-dev linux-kernel-headers pkg-config libgnutls-dev

Please report problems (and successes) to the mailing list.

Unpacking and configuring kvm components

You may wish to take a look at the Kernel-optimizations page. There exists a patch which will change the SDL keygrab combination from ctrl-alt to ctrl-alt-shift. It was written primarily to deal with the heavy use of ctrl-alt-delete in NT-based VMs.

If you are using a patched kernel (e.g. a recent -mm kernel or the kvm git tree), configure the kernel normally, boot into it, and:

tar xzf kvm-release.tar.gz
cd kvm-release
./configure --prefix=/usr/local/kvm --with-patched-kernel
make
sudo make install
sudo /sbin/modprobe kvm-intel
# or: sudo /sbin/modprobe kvm-amd

If you're not running a patched kernel:

tar xzf kvm-release.tar.gz
cd kvm-release
./configure --prefix=/usr/local/kvm
make
sudo make install
sudo /sbin/modprobe kvm-intel
# or: sudo /sbin/modprobe kvm-amd

Creating a disk image for the guest

/usr/local/kvm/bin/qemu-img create -f qcow vdisk.img 10G

Installing a guest operating system

sudo /usr/local/kvm/bin/qemu-system-x86_64 -hda vdisk.img -cdrom /path/to/boot-media.iso \
   -boot d  -m 384

    *

      (kvm doesn't make a distinction between i386 and x86_64 so even in i386 you should use qemu-system-x86_64)

If you're installing Windows, forcing your emulated machine to not have ACPI support by using -no-acpi could result in much faster installation and performance while running. See Windows ACPI Workaround for details.

If you have less than 1GB of memory don't use the -m 384 flag (which allocates 384 MB of RAM for the guest). For computers with 512MB of RAM it's safe to use -m 192, or even -m 128 (the default)

Running the newly-installed guest

sudo /usr/local/kvm/bin/qemu-system-x86_64 vdisk.img -m 384

or a slightly more complicated example, where it is assumed that bridged networking is available on tap0; see Kernel-optimizations for some setup hints:

/usr/local/kvm/bin/qemu-system-x86_64 -hda xp-curr.img -m 512 -soundhw es1370 -no-acpi -snapshot -localtime -boot c -usb -usbdevice tablet -net nic,vlan=0,macaddr=00:00:10:52:37:48 -net tap,vlan=0,ifname=tap0,script=no

    *

      (kvm doesn't make a distinction between i386 and x86_64 so even in i386 you should use qemu-system-x86_64)

论坛徽章:
0
5 [报告]
发表于 2008-01-14 12:58 |只看该作者
网卡可以作为桥把。。
-net nic[,vlan=n][,macaddr=addr][,model=type]

  建立一个虚拟网卡,并把它连接到VLAN的n端口上。

-net tap[,vlan=n][,fd=h][,ifname=name][,=file]
  把主机的TAP网络接口连接到VLAN的n端口上,并使用指定的脚本进行初始化

论坛徽章:
0
6 [报告]
发表于 2009-09-07 12:08 |只看该作者
需要CPU支持虚拟化技术。

论坛徽章:
0
7 [报告]
发表于 2009-09-07 13:07 |只看该作者
可以到
www.gotokvm.com
去看看
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP