how to change kvm default storage position.
来源:互联网 发布:上证综指月度数据下载 编辑:程序博客网 时间:2024/06/05 04:16
copy from this site
How to change default location of libvirt VM images
Question: I am using libvirt and virt-manager to create VMs on my Linux system. I noticed that the VM images are stored in /var/lib/libvirt/images directory. Is there a way to change the default location of VM image directory to something else?
libvirt and its GUI front-end virt-manager can create and manage VMs using different hypervisors such as KVM and Xen. By default, all the VM images created via libvirt go to /var/lib/libvirt/images directory. However, this may not be desirable in some cases. For example, the disk partition where /var/lib/libvirt/images lives may have limited free space. Or you may want to store all VM images in a specific repository for management purposes.
In fact, you can easily change the default location of the libvirt image directory, or what they call a “storage pool.”
There are two ways to change the default storage pool.
Method One: Virt-Manager GUI
If you are using virt-manager GUI program, changing the default storage pool is very easy.
Go to “Edit” -> “Connection Details” in virt-manager menu GUI.
You will see the default storage pool as shown below. On the left bottom of the window, click on the cross icon, which will stop the default storage pool. Once the pool is stopped, click on the trash bin icon on the right, which will delete the pool. Note that this action will NOT remove the VM images inside the pool.
Now click on the plus icon on the far left to add a new storage pool.
Type in the name of a new storage pool (e.g., default), and choose the type of the pool. In this case, choose a “filesystem directory” type since we are simply changing a storage pool directory.
Type in the path of a new storage pool (e.g., /storage).
At this point, the new storage pool should be started, and automatically used when you create a new VM.
Method Two: Virsh Command-Line
Another method to change the default storage pool directory is to use virsh command line utility which comes with libvirt package.
First, run the following command to dump XML definition of the default storage pool.
$ virsh pool-dumpxml default > pool.xml
Open this XML file with a text editor, and change element from /var/lib/libvirt/images to a new location.
<pool type='dir'> <name>default</name> <uuid>0ec0e393-28a2-e975-feec-0c7356f38d08</uuid> <capacity unit='bytes'>975762788352</capacity> <allocation unit='bytes'>530052247552</allocation> <available unit='bytes'>445710540800</available> <source> </source> <target> <path>/var/lib/libvirt/images</path> <permissions> <mode>0711</mode> <owner>-1</owner> <group>-1</group> </permissions> </target></pool>
Remove the current default pool.
$ virsh pool-destroy defaultPool default destroyed
Now create a new storage pool based on the updated XML file.
$ virsh pool-create pool.xmlPool default created from pool.xml
At this point, a default pool has been changed to a new location, and is ready for use.
- how to change kvm default storage position.
- How to Change Default Audio Device
- How to Change the Default System Fonts
- How to change the SQL Server 2008 default install path
- How to change default form name "aspnetForm" in Beta 2
- How to change the SQL Server 2008 default install path
- How to change your default locale on Ubuntu Linux
- how to change the default mode of a linux device
- How to change the default browser in Visual Studio
- how to change the implicit default settings in django 1.6
- How to change mysql default data directory in Ubuntu
- How to change the default stack size on different platforms
- How to Change default MySQL Data Directory in Linux111
- Windows - How to change default system font in Windows 10
- Perforce Tip: how to apply my default change to the release branch
- How to change the default browser to debug with in Visual Studio 2008?
- how to use kvm
- How to change the default run level of a RedHat 9.0 or Fedora Core Linux system
- YUV颜色编码
- JCenter下载太慢?教你修改Maven仓库地址为国内镜像
- POJ 2318 Toys(判断点在直线的方向)
- 第九章自定义标签第二节利用标签输出“自定义标签”到客户端
- matlab画图函数汇总(一)
- how to change kvm default storage position.
- 两个多项式相加及相乘
- “存钱问题”遇到的问题
- 一张图理解prototype、proto和constructor的三角关系
- codeforces 853A
- 区间相交问题(贪心)-算法设计与分析
- Ubuntu中使用virtualenv安装tensorflow
- codeforces 891B
- 数制转换