在vmbuilder命令中创建vm时,可以通过参数虚拟机第一次启动的时候执行的脚本文件。但是由于这个时候虚拟机网络可能还不通,必须要延迟一会儿,才能保证一些apt-get install命令能够顺利执行。下面的脚本是我常用的,贡献出来:boot.sh文件内容:
- # Set time zone
- cp /usr/share/zoneinfo/Asia/Harbin /etc/localtime
- # Set proxy server
- echo "Acquire::http::Proxy "http://10.112.18.178:3142";" >> /etc/apt/apt.conf
- while (! ping -c 1 www.baidu.com); do sleep 1; done
- echo "apt-get install acpid" >> /opt/x
- apt-get install acpid
第一行设置时区第二行设置代理第三行等待ping通www.baidu.com后面安装acpidvmbuilder的参数添加:--firstboot=/var/lib/libvirt/images/$1/boot.sh 我原来测试脚本是bash,但是不能在boot.sh中执行,奇怪,不过先放在这里,以后还有用。
- # Test Internet connection is ok or not
- # If failed 10 times, exit
- # Return immediately if network is ok
- i=0
- count=10
- while [ $i -lt $count ]
- do
- echo "testing"
- let i++
- ping -c2 www.baidu.com > /dev/null
- r=$?
- echo $r
- if [ $r -ne 0 ]
- then
- echo "network is down"
- sleep 10
- else
- echo "network is up"
- let i=count+1
- fi
- done
Linux使用dd命令测试硬盘读写速度KVM虚拟机关闭相关资讯 KVM KVM虚拟机 KVM创建虚拟机
- 使用Shell脚本监控KVM虚拟机 (06月17日)
- 怎样在 Ubuntu 和 Debian 中通过命 (02月29日)
- RHCSA 系列(十五): 虚拟化基础 (10/07/2015 15:25:43)
| - 调整KVM虚拟机硬盘大小 (05月11日)
- KVM嵌套虚拟化配置 (11/20/2015 20:16:53)
- Ubuntu下使用KVM+Qemu 搭建虚拟机 (10/04/2015 06:48:51)
|
本文评论 查看全部评论 (0)