0

mount qcow2 with libguestfs

sometimes you have multiple qcow2 files sitting around from older upgrades and OS's that you just need to grab a file or a config from and dont want to bother with booting it up. there is a way to mount the filesystem using libguestfs which can save time!

This works with LVM and non LVM qcow2 files and also even if you dont know how the qcow2 partitions are laid out you can feed it a bogus partition and it will list it for you.


# guestmount -a rhel5.qcow2 -m /dev/sdzz1 /mnt
libguestfs: error: mount_options: mount_options_stub: /dev/sdzz1: No such file or directory
guestmount: '/dev/sdzz1' could not be mounted.
guestmount: Did you mean to mount one of these filesystems?
guestmount: /dev/sda1 (ext3)
guestmount: /dev/rhel5vg/root (ext3)
guestmount: /dev/rhel5vg/swap (swap)
# guestmount -a rhel5.qcow2 -m /dev/rhel5vg/root /mnt

now goto /mnt and you will see the FS mounted.

to unmount just umount /mnt

jlim0930

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.