qcow2¶
Mount and edit a qcow2 volume¶
Install guestfs-tools:
debian/ubuntu:
List the partitions:
# sudo guestfish -a amazon-linux-2-template.qcow2
Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.
Type: βhelpβ for help on commands
βmanβ to read the manual
βquitβ to quit the shell
><fs> run
100% β¦ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ§ 00:00
><fs> list-filesystems
/dev/sda1: xfs
/dev/sda128: unknown
Mount it:
$ sudo guestmount -a amazon-linux-2-template.qcow2 -m /dev/sda1 /mnt
$ sudo ls /mnt/
bin boot dev etc home lib lib64 local media mnt opt proc root run sbin srv sys tmp usr var
Edit files on qcow2 image (optional):
/mnt/etc/password
/mnt/etc/resolv.conf
/mnt/etc/ssh/sshd_config
Unmount it: