【gentoo】kvm 配置

1. 看cpu是否支持虚拟化

egrep '(vmx|svm)' --color=always /proc/cpuinfo

2. 打开bios的cpu虚拟化支持

3. 配置kernel

    

[*] Virtualization --->
    --- Virtualization
    <M> Kernel-based Virtual Machine (KVM) support
    < >   KVM for Intel processors support 
    < >   KVM for AMD processors support
Device Drivers --->
    [*] Network device support --->
            <M> Universal TUN/TAP device driver support

Networking support --->
    Networking options --->
        <*> 802.1d Ethernet Bridging
        <*> 802.1Q VLAN Support

Processor type and features --->
    [*] Paravirtualized guest support  --->
            [*]   KVM paravirtualized clock                                                     
            [*]   KVM Guest support                                                             
            -*-   Enable paravirtualization code
            [*]     Paravirtualization layer for spinlocks

Processor type and features --->
    [*] Enable KSM for page merging

4.  make && make modules_install

5.重启之后

modprobe kvm
modprobe kvm-intel
modprobe tun
6. 安装包

emerge -av qemu-kvm  bridge-utils usermode-utilities iptables libvirt
7
qemu-img create -f qcow2 -o preallocation=metadata gentoo-i386.img 10G
8
emerge -av bridge-utils
brctl addbr br0
ifconfig br0 192.168.1.1 netmask 255.255.255.0 up
9
emerge -av usermode-utilities
tunctl -b -u USER -t tap0
10
brctl addif br0 tap0
ifconfig tap0 up 0.0.0.0 promisc

11

qemu-kvm -cpu host -smp 2 -m 2G -drive file=PATH,cache=writeback,ifname=virtio gentoo-i386.img -cdrom livecd-i686-installer-2007.0.iso -boot d -vnc 0.0.0.0:1 -net nic,macaddr=00:00:00:00:00:01 -net tap,ifname=tap0,script=no,downscript=no
12
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.0/24 -j SNAT --to-source LOCAL_IP
到此整个虚拟机安装过程结束


其他qemu功能:

1. 创建qemu 副本(基于最初的img文件)

qemu-img create -b gentoo-i386.img -f qcow2 gentoo-i386.img.1
2 复制qemu 镜像文件
qemu-img convert gentoo-i386.img -O qcow2 gentoo-i386.img.1


添加nat

iptables -t nat -A PREROUTING -i eth0 -d $ETH_IP  -j DNAT --to-destination $TARGET_IP
iptables -t nat -A POSTROUTING -d $TARGET_IP  -j SNAT --to-source $BR0_IP

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值