Modify QCOW2 images using guestfish

If we want to modify the QCOW2 image that we have just created or the one that is downloaded from the Internet, without booting, we could do so by using the guestfish utility. This is provided by the libguestfs library.

Installing guestfish

The installation of guestfish is fairly simple.

apt-get install libguestfs-tools

On some versions (like 12.04), the command is apt-get install guestfish. It will also ask for the creation of the virtual appliance; please do so. Once the appliance is installed, you can then execute the command sudo guestfish (or as root).

Loading the images

Once in the guestfish console, you can then load the qcow2 image by typing the command add <full path to qcow2 imange>.

add /home/alokas/mysql.qcow2 ...

Get OpenStack Trove Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.