Sometimes I need to edit files inside qcow2 or raw image, but for some reason I don’t want to launch the image in KVM or in Openstack cloud. The image can be edited offline using virt-edit tool.
Installing libguestfs-tools (provides virt-edit):
[root@tuxfixer ~]# yum install libguestfs-tools
Editing files inside image, examples:
[root@tuxfixer ~]# virt-edit image.img /etc/hosts
[root@tuxfixer ~]# virt-edit image.qcow2 /etc/hosts
Note: the format of the disk image (raw|qcow2) is auto-detected.
Thank you, it couldn’t have been more timely, resolved a significant problem for me.