Mounting QCOW2 Disk

QCOW2 is a disk image format which used by QEMU virtualization software.

Install Software:

root@ankara:~# apt-get install libguestfs-tools

Create a directory for the mount point.

root@ankara:/data/rhcevms# mkdir /mnt/qcow2

Mounting qcow2 disk

If you do not know the disk partition name you can use bogus partition name. In this case I used “asssd”. guestmount showed me available partitions on the disk. I mounted qcow2 read-only mode. Do not mount running virtual system disk image as you most probably destroy the disk image.

root@ankara:/data/rhcevms# guestmount -a centos7.qcow2 -m /dev/asssd --ro /mnt/qcow2/
libguestfs: error: mount_options: mount_options_stub: /dev/asssd: No such file or directory
guestmount: '/dev/asssd' could not be mounted.
guestmount: Did you mean to mount one of these filesystems?
guestmount: 	/dev/sda1 (xfs)
guestmount: 	/dev/cl/root (xfs)
guestmount: 	/dev/cl/swap (swap)

I choose /dev/cl/root (lvm disk)

root@ankara:/data/rhcevms# guestmount -a centos7.qcow2 -m /dev/cl/root --ro /mnt/qcow2/
root@ankara:/data/rhcevms# cd /mnt/qcow2/
root@ankara:/mnt/qcow2# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@ankara:/mnt/qcow2# cat etc/hosts   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
root@ankara:/mnt/qcow2# cat etc/resolv.conf 
# Generated by NetworkManager
search sfp.local
root@ankara:/mnt/qcow2# cat etc/hostname 

Umounting the disk

root@ankara:/data/rhcevms# cd
root@ankara:~# umount /mnt/qcow2






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.