Perhaps not many know libguestfs, a library written in C and a set of tools that allow you to access and modify the virtual disk images used in virtual machines. In addition, you will be able to work with several Linux KVM-based virtualization platforms, and the VM images will be mounted directly on the host using the FUSE module and the guestmount/guestunmount tools.
Another nice thing about libguestfs is that can access almost any FS, or file system, and that includes all Linux (ext2, ext3, ext4, XFS, btrfs,…), MS Windows (VFAT and NTFS), macOS (HFS and HFS+), as well as BSD, and even LVM2 volume management. All this in both MBR and GPT.
As for virtual disk types which you can access, can be:
- VirtualBox .vdi
- VMWare .vmdk
- Hyper-V .vhd and .vhdx
You can also access and modify files, local devices, ISO images, SD memory cards, or do it remotely via protocols on the table:
- sheep dog
Furthermore, libguestfs does not need privileges, which is also interesting. Thanks to this project, you will have various command line tools like guestfish, guestmount, guestunmount, virt-rescue to fix unbootable VMs, virt-cat, virt-tar, etc.
libguestfs also acts as an API to be able to link management programs in various programming languages:
You can also use it from scripts, which is very practical when administering systems. Also, this project by Richard Jones can be installed from the repos of many of the well-known distros in this way:
- Debian / Ubuntu and derivatives
sudo apt install libguestfs-tools
- Fedora/CentOS/RHEL and derivatives
sudo dnf install libguestfs
- Arch Linux and derivatives
sudo pacman -Sy libguestfs
By the way, if you're using libvirt and you try to invoke any of the utilities or tools included in libguestfs, you will receive a error like this:
libguestfs: error: could not create appliance through libvirt.
La solution it's as simple as exporting a variable as "direct" like so:
More information - Official Web site