How To Clone VM with Libguestfs? – POFTUT

How To Clone VM with Libguestfs?

Hi, today we will look disk image tools/library which is very powerful. We will look for now just the tools, not the library but in the future, we can investigate the library in c or python too. With the era of cloud computing things to be done very fast, practical and precise way. In the past system administrators was connecting systems one by one and complete operations. But now in the new era system, admins do not have much time to do all things so new emerging technologies/tools/… is coming. One of them is libguestfs tools which make manipulating and operating virtual machine disk images very easy. A typical scenario is that a system administrator creates a new VM and install some applications on it and we change root pass and then clone a git repository into the system without touching systems console or terminal.

Clone Script

Here is a simple script which I use daily. I create source and dest paths that provide disk images. And then use virt-clone tool to clone existing VM with new disk path and name –auto-clone option makes is very easy. –connect option sets the hyper-visor –original sets source VM domain name. –name option is used new VMS name. and –file option for new VM disk file path.

Install Applications To The Image

Now we have a new VM but we have to do a lot of work to complete operation. But with this tool it is easy. Here we use virt-customize command with -d option which means the name of VM nad –install option which specifies the package names that will be installed.

LEARN MORE  How To Install VMware Tools To The Linux Debian, Ubuntu, Kali, Mint, Fedora, CentOS, RHEL Distributions

Change Root Password Of Image

Here we change the root password and then run scripts to clone testing repository for git. Now we can give the system to the developers. As you can see it is very easy we write just their line of script and do a lot of thing for little tiny time.

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)