guestmount
guestmount is a utility from the libguestfs suite that allows you to mount a virtual machine disk image (or any supported guest filesystem) on your host system without booting the virtual machine.
Purpose
Access and manipulate files within VM disk images directly from the host.
Useful for inspection, recovery, or injecting/removing files.
Common Use Cases
Debugging or viewing guest log/config files.
Copying files into or out of a VM disk image.
Performing forensics on a VM image.
Rescuing files from an unbootable image.
Modifying or patching guest environments.
Basic Syntax
guestmount -a <disk.img> -m <mount_point> <host_directory>Example:
Mount /dev/sda1 from disk.qcow2 image in read-only mode to /mnt/vm:
guestmount -a disk.qcow2 -m /dev/sda1 --ro /mnt/vmUse -i for automatic partition detection:
guestmount -a disk.qcow2 -i --ro /mnt/vmOptions
-a
Specify disk image
-i
Auto-detect guest OS and partitions
-m
Specify guest partition to mount
--ro
Mount as read-only
--rw
Mount with read/write access (use cautiously)
--trace
Enable backend call debugging
Filesystem Support
Raw, qcow2, vmdk, vdi, img
Supports partitioned filesystems, LVM, and more.
Unmounting Always unmount with:
guestunmount /mnt/vmSecurity Notes
Use
--roto avoid accidental changes.--rwmay require root and can risk image corruption.Do not expose guest filesystems to untrusted scripts or users.
Last updated