Gentoo 啟動 init 機制不同於 Debian 和 Redhat, 具體細節尚未總結。
現備份一 KVM tap 啟動指令碼:kvm_net
#!/sbin/runscript# Copyright chencheng use kvm# Distributed under the terms of the GNU General Public License v2# $Header: $user_id=999dev_num=3depend() { need net.br0 need modules}start() { ebegin "Start kvm-net" /sbin/modprobe kvm-intel #tapx=`tunctl -u nehc|awk '{print $2}'|cut -c 2,3,4,5` for((i=0;i<${dev_num};i++)) do tapx=`/usr/bin/tunctl -b -u ${user_id}` brctl addif br0 ${tapx} ifconfig ${tapx} promisc up echo "${tapx} ready now! " done eend $?}stop() { ebegin "Stop kvm-net" for((i=0;i<${dev_num};i++)) do brctl delif br0 tap$i ifconfig tap$i down tunctl -d tap$i done /sbin/modprobe -r kvm-intel eend $?}restart() { stop start}
啟動指令碼不同於普通指令碼在於可以:rc-update add kvm-net 將 kvm-net 加入運行層級
另外,貼一 kvm 指令碼:start_kvm
#!/bin/bash# created by chencheng# use it to start virtual machine # $1 refer machine name# $2 refer tap namekvm -net nic,macaddr=00:00:00:00:00:00 -net tap,ifname=$2,script=no,downscript=no -m 300 /home/nehc/vms/$1/$1.img -daemonize
這個就簡單啦 ....