个人工具
登录
查看“UbuntuHelp:KVM/Virsh”的源代码 - Ubuntu中文
UbuntuHelp
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“UbuntuHelp:KVM/Virsh”的源代码
来自Ubuntu中文
←
UbuntuHelp:KVM/Virsh
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{{From|https://help.ubuntu.com/community/KVM/Virsh}} {{Languages|UbuntuHelp:KVM/Virsh}} You can create, delete, run, stop, and manage your virtual machines from the command line, using a tool called ''virsh''. ''Virsh'' is particularly useful for advanced Linux administrators, interested in script or automating some aspects of managing their virtual machines ==== Installing ==== Install ''virsh'': <pre><nowiki> sudo apt-get install virsh </nowiki></pre> ==== Connecting ==== Connect to your hypervisor. This can be local, or even remote. In most cases, if you want to manage VMs running on the local hypervisor: <pre><nowiki> $ virsh connect qemu:///system Connecting to uri: qemu:///system </nowiki></pre> ==== Listing VMs ==== <pre><nowiki> $ virsh list Id Name State ---------------------------------- 1 foo running </nowiki></pre> ==== Creating a Virtual Machine ==== Virtual Machines managed by ''virsh'' are created by describing the virtual machine in a ''libvirt'' XML file, and importing that XML file into ''virsh''. You can export the XML of an existing virtual machine: <pre><nowiki> $ virsh dumpxml foo > /tmp/foo.xml Connecting to uri: qemu:///system </nowiki></pre> And then edit <code><nowiki>/tmp/foo.xml</nowiki></code>, which should be rather straightforward. For more information about ''libvirt'' XML format, see: * http://libvirt.org/format.html Once you have an XML file describing the new virtual machine you want to create, import it into virsh, and run it immediately: <pre><nowiki> $ virsh create /tmp/foo_new.xml Connecting to uri: qemu:///system Domain foo_new created from /tmp/foo_new.xml $ virsh list Connecting to uri: qemu:///system Id Name State ---------------------------------- 3 foo_new running </nowiki></pre> Alternatively, if you want to define it, but not run it, you could have used: <pre><nowiki> $ virsh define /tmp/foo_new.xml </nowiki></pre> ==== Working with a Running Virtual Machine ==== Once a virtual machine is running, you can manage it in many different ways, such as: <pre><nowiki> $ virsh start foo </nowiki></pre> <pre><nowiki> $ virsh reboot foo </nowiki></pre> <pre><nowiki> $ virsh shutdown foo </nowiki></pre> <pre><nowiki> $ virsh suspend foo </nowiki></pre> <pre><nowiki> $ virsh resume foo </nowiki></pre> You can also affect the memory, dynamically attach devices, interfaces, modify the networking configuration, etc. This guide in this wiki page is clearly not comprehensive. For a complete description of ''virsh'' commands, see: <pre><nowiki> $ man virsh </nowiki></pre> ===== Console ===== Sometimes, it's useful to attach to the console of a running VM, to obtain debugging information, etc. <pre><nowiki> $ virsh console foo Connected to domain foo Escape character is ^] </nowiki></pre> ===== Details ===== To view the details about a particular virtual machine: <pre><nowiki> $ virsh dumpxml foo </nowiki></pre> These can be saved to a file, modified, and imported again using: <pre><nowiki> $ virsh define foo </nowiki></pre> ==== Deleting a Virtual Machine ==== To delete a virtual machine, first terminate it (if running), and then undefine it: <pre><nowiki> $ virsh destroy foo_new $ virsh undefine foo_new </nowiki></pre> ==== More Information ==== For more complete documentation on ''virsh'', see: * http://manpages.ubuntu.com/manpages/karmic/en/man1/virsh.1.html [[category:UbuntuHelp]]
该页面使用的模板:
模板:From
(
查看源代码
)
模板:Languages
(
查看源代码
)(受保护)
模板:Languages/Lang
(
查看源代码
)(受保护)
返回至
UbuntuHelp:KVM/Virsh
。