xrdp、kvm、qemu、virt-manager建立鏡像和虛擬機

xrdp實現遠程桌面鏈接,能夠直接經過windows mstsc來鏈接Linux直接鏡像以及經過virtual-manager調試python

#####xrdp安裝ios

apt-get update
apt-get install xrdp
apt-get install vnc4server 
apt-get install xubuntu-desktop 
echo "xfce4-session" >~/.xsessiongit

mstsc  遠程鏈接
帳號密碼就是服務器的帳號密碼ubuntu

qemu 版本不對影響virt-manager製做Windows鏡像的啓動
dpkg -l |grep qemu
ii  ipxe-qemu                                 1.0.0+git-20131111.c3d1e78-2ubuntu1.1               all          PXE boot firmware - ROM images for qemu
ii  qemu                                      2.0.0+dfsg-2ubuntu1.34                              amd64        fast processor emulator
ii  qemu-block-extra:amd64                    1:2.5+dfsg-5ubuntu10.14~cloud0                      amd64        extra block backend modules for qemu-system and qemu-utils
ii  qemu-keymaps                              2.0.0+dfsg-2ubuntu1.34                              all          QEMU keyboard maps
ii  qemu-kvm                                  2.0.0+dfsg-2ubuntu1.34                              amd64        QEMU Full virtualization
ii  qemu-slof                                 20151103+dfsg-1ubuntu1~cloud0                       all          Slimline Open Firmware -- QEMU PowerPC version
ii  qemu-system                               2.0.0+dfsg-2ubuntu1.34                              amd64        QEMU full system emulation binaries
ii  qemu-system-arm                           2.0.0+dfsg-2ubuntu1.34                              amd64        QEMU full system emulation binaries (arm)
ii  qemu-system-common                        2.0.0+dfsg-2ubuntu1.34                              amd64        QEMU full system emulation binaries (common files)
ii  qemu-system-mips                          2.0.0+dfsg-2ubuntu1.34                              amd64        QEMU full system emulation binaries (mips)
ii  qemu-system-misc                          2.0.0+dfsg-2ubuntu1.34                              amd64        QEMU full system emulation binaries (miscelaneous)
ii  qemu-system-ppc                           2.0.0+dfsg-2ubuntu1.34                              amd64        QEMU full system emulation binaries (ppc)
ii  qemu-system-sparc                         2.0.0+dfsg-2ubuntu1.34                              amd64        QEMU full system emulation binaries (sparc)
ii  qemu-system-x86                           2.0.0+dfsg-2ubuntu1.34                              amd64        QEMU full system emulation binaries (x86)
ii  qemu-user                                 1:2.5+dfsg-5ubuntu10.14~cloud0                      amd64        QEMU user mode emulation binaries
ii  qemu-user-binfmt                          1:2.5+dfsg-5ubuntu10.14~cloud0                      amd64        QEMU user mode binfmt registration for qemu-user
ii  qemu-utils                                2.0.0+dfsg-2ubuntu1.34                              amd64        QEMU utilitieswindows

qemu
qemu-kvm
qemu-system 
qemu-system-common   
qemu-system-x86    
qemu-utils     
####主要是以上模塊版本要匹配
apt-cache show qemu
經過這個能夠查看現有源裏面存在的版本,若是沒有的話能夠先添加源,或者某個源不須要的話要能夠幹掉
apt-get update
先裝qemu  apt-get install qemu=2.0.0+dfsg-2ubuntu1.34
在裝emu-system-common    apt-get install emu-system-common=2.0.0+dfsg-2ubuntu1.34
後面的沒有順序,隨便裝服務器

apt-get -y install kvm qemu virtinst python-libvirt virt-viewer virt-managersession

###查看機器自己知否支持kvm,若是有輸出表示支持
egrep "vmx|svm" /proc/cpuinfoui

###查看kvm是否加載,有輸出表示有加載
lsmod |grep kvm   spa

###如若沒有,手動加載
modprobe kvm
modprobe kvm-intel
lsmod |grep kvm
操作系統

#####若是支持虛擬化,可是手動加載又報錯

modprobe: ERROR: could not insert 'kvm_intel': Operation not supported

modprobe: ERROR: could not insert 'kvm_amd': Operation not supported

能夠看下系統日誌 grep kvm /var/log/dmesg

kvm: disabled by bios ###若顯示此消息,說明系統啓動的時候沒有加載,須要

重啓系統,進入BIOS開啓虛擬化支持

####查看qemu版本
qemu-system-x86_64 --version

####開始安裝鏡像,由於製做的時候須要用戶界面,因此得在圖形界面下來製做,系統自己得支持GUI
####window
qemu-img create -f qcow2 win2008_x64.qcow2 20g
###建立一個qcow2格式的容器,名字爲win2008_x64.qcow2,磁盤大小爲20G,切換在這裏設置了磁盤大小,後續不可更改,因此按照本身的需求提早設置好
qemu-img convert -p -O raw win7x64_v2v.qcow2 win7x64_v2v.raw
####qcow2與raw格式轉換,上述是qcow2轉換成raw,反着轉換也是OK的,raw是老的格式,佔用空間大,可是速度比較妥當,不支持一些新的功能

qemu-system-x86_64 -m 4096 -enable-kvm -drive file=win7_x64_a.qcow2,if=virtio -cdrom cn_windows_7_ultimate_with_sp1_x64_dvd_u_677408.iso \
 -fda virtio-win-0.1.126_amd64.vfd -net nic,model=virtio -net user -boot d

###直接把ISO寫入容器製做鏡像
-m 內存
-enable-kvm  開啓kvm加速
-drive    容器
if=virtio   是否存在virtio類型
-fda     Windows驅動文件,安裝的時候必需要,不然沒法安裝成功,http://fedoraproject.org/wiki/Windows_Virtio_Drivers#Direct_download;下載地址

#####問題
一、安裝的時候,若是hypervisor選擇的kvm,直接顯示黑屏,提示....has not dssplay (yet)
二、hypervisor選擇qemu,直接黑屏,啥都沒有,
####方法,查看qemu的版本,若是太新的話能夠選擇下降qemu版本,
dpkg -l|grep qemu   ###查看qemu全部依賴的版本
apt-get install qemu-system-x86=2.0.0+dfsg-2ubuntu1.34  ###直接安裝對應的版本便可


Linux建立
qemu-system-x86_64 -m 1024 -enable-kvm xx.qcow2 -cdrom xx.iso


####virt-manager建立虛擬機
一、直接用上面建立好的鏡像導入,作一遍校驗
二、直接下載iso,而後和安裝操做系統同樣安裝便可
####主要牽涉到幾個地方的選擇

virsh 能夠管理虛擬機 virsh list  查看當前正在運行的虛擬機 virsh kill  id or name    ###能夠直接幹掉正在運行的虛擬機 virsh undefine  name   ####直接移除建立的虛擬機

相關文章
相關標籤/搜索