歡迎您光臨本站 註冊首頁

小實驗: 使用KVM虛擬機,安裝一個windows系統

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

小實驗: 使用KVM虛擬機,安裝一個windows系統

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

http://blog.chinaunix.net/upfile/070901173555.png
《解決方案》

頂一下,不會跟正在用的xen衝突吧?:lol:
《解決方案》

gcc要加--disable-gcc-check參數,modprobe kvm-amd 或者modprobe kvm-intel 出錯,
# modprobe kvm-amd
FATAL: Module kvm_amd not found.
# 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虛擬機軟體,真暈:mrgreen:
《解決方案》

網卡默認工作在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)
《解決方案》

網卡可以作為橋把。。
-net nic[,vlan=n][,macaddr=addr][,model=type]

  建立一個虛擬網卡,並把它連接到VLAN的n埠上。

-net tap[,vlan=n][,fd=h][,ifname=name][,=file]
  把主機的TAP網路介面連接到VLAN的n埠上,並使用指定的腳本進行初始化
《解決方案》

需要CPU支持虛擬化技術。
《解決方案》

可以到
www.gotokvm.com
去看看

[火星人 ] 小實驗: 使用KVM虛擬機,安裝一個windows系統已經有889次圍觀

http://coctec.com/docs/service/show-post-6156.html