初始環境:ubuntu14.04
apt-get install qemu-kvm libvirt-bin virtinst
apt-get install vnc4server
apt-get install gnome-panel
啓動vncserver
#vncserver
New 'gitlab:6 (root)' desktop is gitlab:6
編輯啓動腳本
/root/.vnc/xstartup
在&x-window-manager & 增加#
然後再最下面增加2行
startgnome &
DISPLAY=:1 gnome-session &
重啓VNC服務
vncserver -kill :6
注意:6號段要匹配
然後再啓動vnc服務輸入vnc4server
第0步:準備
qemu-img create -f qcow2 win7.qcow2 10G
第一步:
kvm -m 4096 -cdrom win7.iso -drive file=win7.qcow2,if=virtio,boot=on -fda virtio-win-1.1.16.vfd -boot d -nographic -vnc 192.168.30.8:15
vncserver打開,輸入地址:192.168.30.8:15 即可。
第二步:
注意,在安裝過程中加載驅動程序,從軟盤驅動選擇驅動程序win7,不要從光驅或其它。
第三步:安裝完畢後,配置相關內容,如關裝防火、開啓遠程桌面等
第四步:關機,重新啓動:
kvm -m 4096 -drive file=win7.qcow2,if=virtio,boot=on -cdrom virtio-win-0.1-30.iso -net nic,model=virtio -net user -boot c -nographic -vnc 192.168.30.8:15
設備管理->網絡適配器,從CDROM更新,並機上傳鏡像
第五步:
將共享的文件夾製作成一個iso掛載上去即可共享。
常用工具爲:anytoiso
實際上是掛載一個共享盤,在磁盤管理裏面添加到windows裏面。可以將cloud-init相關包、office相關包打成iso
kvm -m 4096 -drive file=win7.qcow2,if=virtio,boot=on -cdrom myiso.iso -net nic,model=virtio -net user -boot c -nographic -vnc 192.168.30.8:15
注意修改cloud-init配置,去掉自動修改密碼,否則重啓後自動修改密碼