[root@foundation3 ~]# virt-install --name mo1 --ram 1024 --file /var/lib/li bvirt/images/mo1.img --cdrom /root/Desktop/rhel-server-7.1-x86_64-dvd.iso - -file-size 8 WARNING No operating system detected, VM performance may suffer. Specify an OS with --os-variant for optimal results. WARNING CDROM media does not print to the text console by default, so you likel y will not see text install output. You might want to use --location.See the man page for examples of using --location with CDROM media Starting install... Allocating 'mo1.img' | 8.0 GB 00:00 Creating domain... | 0 B 00:00 Connected to domain mo1
[root@foundation3 ~]# ls /etc/libvirt/qemu /var/lib/libvirt/images/ /etc/libvirt/qemu: desktop.xml <span style="color:#ff0000;">mo.xml</span> networks server.xml /var/lib/libvirt/images/: mo1.img rh124-desktop-vda.qcow2 rh124-server-vda.ovl rh124-server.xml <span style="color:#ff0000;">mo.img</span> rh124-desktop-vdb.ovl rh124-server-vda.qcow2 test.sh mo_shot.qcow2 rh124-desktop-vdb.qcow2 rh124-server-vdb.ovl vm1.qcow2 rh124-desktop-vda.ovl rh124-desktop.xml rh124-server-vdb.qcow2
[root@foundation3 ~]# virsh list Id Name State ----------------------------------------------------
[root@foundation3 ~]# virsh start mo Domain mo started [root@foundation3 ~]# virsh list Id Name State ---------------------------------------------------- 9 mo running [root@foundation3 ~]# su - mo Last login: Wed Oct 19 10:48:59 CST 2016 on pts/3 [mo@foundation3 ~]$ virsh list Id Name State ----------------------------------------------------
[root@foundation3 ~]# virt-install --name zhao --ram 1024 --file /var/lib/libvirt/images/zhao.img --file-size 8 --cdrom /root/Desktop/rhel-server-7.1-x86_64-dvd.iso WARNING No operating system detected, VM performance may suffer. Specify an OS with --os-variant for optimal results. WARNING CDROM media does not print to the text console by default, so you likely will not see text install output. You might want to use --location.See the man page for examples of using --location with CDROM media Starting install... Allocating 'zhao.img' | 8.0 GB 00:00:00 <span style="color:#ff0000;">ERROR </span> internal error: process exited while connecting to monitor: 2016-10-19T03:00:25.552714Z qemu-kvm: -drive file=/root/Desktop/rhel-server-7.1-x86_64-dvd.iso,if=none,id=drive-ide0-0-1,readonly=on,format=raw: <span style="color:#ff0000;">could not open disk image /root/Desktop/rhel-server-7.1-x86_64-dvd.iso: Could not open file: Permission denied</span> Domain installation does not appear to have been successful. If it was, you can restart your domain by running: virsh --connect qemu:///system start zhao otherwise, please restart your installation.
[root@foundation3 ~]# ll /root/Desktop/rhel-server-7.1-x86_64-dvd.iso -rw-r--r-- 1 qemu qemu 3890216960 Oct 17 22:15 /root/Desktop/rhel-server-7.1-x86_64-dvd.iso
<span style="color:#ff0000;">#user = "root"</span> # The group for QEMU processes run by the system instance. It can be # specified in a similar way to user. <span style="color:#ff0000;">#group = "root"</span> # Whether libvirt should dynamically change file ownership # to match the configured user/group above. Defaults to 1. # Set to 0 to disable file ownership changes. <span style="color:#ff0000;">#dynamic_ownership =0 </span>
[root@foundation3 ~]# virsh list --all Id Name State ---------------------------------------------------- - desktop shut off - mo shut off - server shut off
[root@foundation3 ~]# qemu-img create -f qcow2 -b /var/lib//libvirt/images/mo.img /var/lib/libvirt/images/test.qcow2 Formatting '/var/lib/libvirt/images/test.qcow2', fmt=qcow2 size=8589934592 backing_file='/var/lib//libvirt/images/mo.img' encryption=off cluster_size=65536 lazy_refcounts=off [root@foundation3 ~]# ls /var/lib/libvirt/images/ mo1.img rh124-desktop-vdb.ovl rh124-server-vdb.ovl vm1.qcow2 mo.img rh124-desktop-vdb.qcow2 rh124-server-vdb.qcow2 zhao.img mo_shot.qcow2 rh124-desktop.xml rh124-server.xml rh124-desktop-vda.ovl rh124-server-vda.ovl <span style="color:#ff0000;">test.qcow2</span> rh124-desktop-vda.qcow2 rh124-server-vda.qcow2 test.sh [root@foundation3 ~]#
#!/bin/bash
create_img()
{
virsh undefine $1 &>/dev/null
qemu-img create -f qcow2 -b /var/lib/libvirt/images/$1.img /var/lib/libvirt/images/$1_shot.qcow2 &>/dev/null
virt-install --name $1 --ram 1024 --disk /var/lib/libvirt/images/$1_shot.qcow2 --import --noautoconsole &>/dev/null
virsh define /etc/libvirt/qemu/$1.xml &>/dev/null
}
delete_img()
{
virsh undefine $1 &>/dev/null
rm -rf /var/lib/libvirt/images/$1_shot.qcow2 &>/dev/null
}
check_status()
{
status=`virsh list --all| sed -n '3,$p'|sed 's/[[:space:]]\+/:/g'|grep $1 |cut -d':' -f4`
echo $status
if [ $status = "shut" ];then
return 0
elif [ $status = 'running' ];then
return 1
fi
}
case $1 in
--start|-s)
shift
echo "start $1 ..."
check_status $1 &>/dev/null && virsh start $1 &>/dev/null
;;
--view|-v)
shift
echo "view $1 ..."
check_status $1 &> /dev/null || virt-viewer $1 &>/dev/null &
;;
--shutdown|-d)
shift
echo "shutdown $1 ..."
check_status $1 &> /dev/null || virsh destroy $1 &>/dev/null &
;;
--create|-c)
shift
check_status $1 &> /dev/null || virsh destroy $1
echo "create snapshot for $1 ..."
create_img $1
echo "success create snapshot"
;;
--reset|-r)
shift
check_status &>/dev/null $1 || virsh destroy $1
delete_img $1
create_img $1
;;
--check|-h)
shift
echo $1 `check_status $1`
;;
*)
echo "vmctl <COMMAND> <OPTIONS> "
echo ""
echo "open,show,shutdown,reset...Virtual Machine"
echo -e "--start|-s\topen Virtual Machine\n--view|-v\tshow the Virtual Machine that has been opened"
echo -e "--shutdown|-d\tclose your Virtual Machine"
echo -e "--create|-c\tcreate a snapshot for your Virtual Machine"
echo -e "--reset|-r\treset your Virtual Machine"
echo -e "--check|-h\tcheck Virtual Machine status running or shut"
;;
esac
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有