Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to change the default location of a libvirt VM image

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How to change the default location of libvirt VM images, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Question: I use libvirt and virt-manager to create virtual machines on my Linux system. I noticed that the virtual machine image is located in the / var/lib/libvirt/images directory. Is there any way to change the default path of virtual machine images?

Libvirt and its GUI front end virt-manager can use different hypervisors to create and manage VM, such as LVM and Xen. By default, all virtual machine images are created to the / var/lib/libvirt/images directory via libvirt. However, sometimes this is not what we want. For example, / var/lib/libvirt/images the disk partition size here is limited. Or you want to store all virtual machines and mirror them to a specific repository for management.

In fact, you can easily change the default directory of libvirt images, or "storage pools".

There are two ways to change the default storage pool.

Method 1: Virt-Manager GUI

If you are using the virt-manager GUI program, it is very easy to change the default storage pool.

Go to the virt-manager menu GUI "Edit"-> "connection details".

You can see the default storage pool as shown below. In the lower left corner of the window, click the fork button and the default storage pool will be stopped. Once the storage pool is stopped, click the trash can on the right and the storage pool will be deleted. Note that this action does not delete the mirror in the pool.

Now click the plus sign on the left to add a new storage pool.

Enter the name of the new storage pool (for example: default) and select the type of storage pool. In this case, we select File system Directory because we are only changing the storage pool directory.

Enter a new storage pool path (for example, / storage).

At this point, the new storage pool should be started and automatically used when you create a new virtual machine.

Method 2: Virsh command line

Another way to change the default storage pool directory is to use the virsh command line tool from the libvirt package.

First, run the following command to export the XML definition of the default storage pool.

$virsh pool-dumpxml default > pool.xml

Open the XML file with a text editor and change the / var/lib/libvirt/images in the node to the new address.

XML/HTML Code copies content to the clipboard

Default

0ec0e393-28a2-e975-feec-0c7356f38d08

975762788352

530052247552

445710540800

/ var/lib/libvirt/images

0711

-1

-1

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, the default pool has been changed to the new address and is ready for use.

After reading the above, do you know how to change the default location of the libvirt VM image? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report