Edit qcow2 or raw image files offline using virt-edit

linux-terminal
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.

One thought on “Edit qcow2 or raw image files offline using virt-edit”

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.