好久好久没写东西了,人果然是会变得很懒很懒的...
最近一直在跟虚拟化打交道,特别是装虚拟机这个。于是就强迫自己写了这么个东西!也是给自己留个纪念什么的~
一:检查机器虚拟化支持
对于Kvm来说,必须要求CPU支持硬件虚拟化。二种方法查看:
- $ cat /proc/cpuinfo
-
processor : 0
-
vendor_id : GenuineIntel
-
cpu family : 6
-
model : 23
-
model name : Intel(R) Core(TM)2 Quad CPU Q9400 @ 2.66GHz
-
stepping : 10
-
cpu MHz : 2660.405
-
cache size : 3072 KB
-
physical id : 0
-
siblings : 4
-
core id : 0
-
cpu cores : 4
-
apicid : 0
-
initial apicid : 0
-
fdiv_bug : no
-
hlt_bug : no
-
f00f_bug : no
-
coma_bug : no
-
fpu : yes
-
fpu_exception : yes
-
cpuid level : 13
-
wp : yes
-
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm tpr_shadow vnmi flexpriority
-
bogomips : 5320.81
-
clflush size : 64
-
cache_alignment : 64
-
address sizes : 36 bits physical, 48 bits virtual
-
power management:
看到/proc/cpuinfo里面有vmx说明CPU支持硬件虚拟化,如果没有,那么...考虑换个CPU?毕竟现在SNB的都全线支持VT-x了~
另外一种就更加Human了~
- $ lscpu
-
Architecture: i686
-
CPU op-mode(s): 32-bit, 64-bit
-
CPU(s): 4
-
Thread(s) per core: 1
-
Core(s) per socket: 4
-
CPU socket(s): 1
-
Vendor ID: GenuineIntel
-
CPU family: 6
-
Model: 23
-
Stepping: 10
-
CPU MHz: 2660.405
-
Virtualization: VT-x
-
L1d cache: 32K
-
L1i cache: 32K
-
L2 cache: 3072K
要是你没这个lscpu的话,自行Google吧,我是Fedora14...
二:安装Kvm包
推荐使用Yum groupinstall:
- $ yum groupinfo 虚拟化
- 已加载插件:langpacks, presto, refresh-packagekit
- Adding zh_CN to language list
- 设置组进程
- 组:虚拟化
- 描述:这些软件包提供了一个虚拟化环境。
- 必要的软件包:
- python-virtinst
- 默认的软件包:
- libvirt
- qemu-kvm
- virt-manager
- virt-viewer
- 可选的软件包:
- virt-top
- # yum groupinstall -y 虚拟化
装完一堆东西以后需要启动libvirtd这个服务:
- # service libvirtd start
- Starting libvirtd daemon: [ OK ]
三:安装Kvm虚拟机
本来想自己写这一步的,觉得还是不够详细,还是贴上Man吧!原谅我偷懒...
- Install a KVM guest (assuming proper host support), creating a
- new storage file, virtual networking, booting from the host
- CDROM, using VNC server/viewer.
- # virt-install \
- --connect qemu:///system \
- --name demo \
- --ram 500 \
- --disk path=/var/lib/libvirt/images/demo.img,size=5 \
- --network network=default,model=virtio \
- --vnc \
- --cdrom /dev/cdrom
- Install a Fedora 9 plain QEMU guest, using LVM partition,
- virtual networking, booting from PXE, using VNC server/viewer
- # virt-install \
- --connect qemu:///system \
- --name demo \
- --ram 500 \
- --disk path=/dev/HostVG/DemoVM \
- --network network=default \
- --virt-type qemu
- --vnc \
- --os-variant fedora9
- Install a guest with a real partition, with the default QEMU
- hypervisor for a different architecture using SDL graphics,
- using a remote kernel and initrd pair:
- # virt-install \
- --connect qemu:///system \
- --name demo \
- --ram 500 \
- --disk path=/dev/hdc \
- --network bridge=eth1 \
- --arch ppc64 \
- --sdl \
- --location
- Run a Live CD image under Xen fullyvirt, in diskless
- environment
- # virt-install \
- --hvm \
- --name demo \
- --ram 500 \
- --nodisks \
- --livecd \
- --vnc \
- --cdrom /root/fedora7live.iso
- Install a paravirtualized Xen guest, 500 MB of RAM, a 5 GB of
- disk, and Fedora Core 6 from a web server, in text-only mode,
- with old style --file options:
- # virt-install \
- --paravirt \
- --name demo \
- --ram 500 \
- --file /var/lib/xen/images/demo.img \
- --file-size 6 \
- --nographics \
- --location
- Create a guest from an existing disk image ’mydisk.img’ using
- defaults for the rest of the options.
- # virt-install \
- --name demo
- --ram 512
- --disk /home/user/VMs/mydisk.img
- --import
Linux的Man真是强悍...
阅读(4166) | 评论(0) | 转发(0) |