Mounting qcow2 image in linux without kvm

Sometime you need to mount qcow2 image without running it . 

install 

apt-get install qemu-utils

Now 

(Note) it needs FULL path to qcow2 image

qemu-nbd -c /dev/nbd0 /scratch/vm/Debian-6.0.6-x86_64-rOCCI.qcow2 

Now you can see partitions 

 

fdisk -l /dev/nbd0

Disk /dev/nbd0: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00075c67

     Device Boot      Start         End      Blocks   Id  System

/dev/nbd0p1   *        2048    12890111     6444032   83  Linux

/dev/nbd0p2        12892158    16775167     1941505    5  Extended

/dev/nbd0p5        12892160    16775167     1941504   82  Linux swap / Solaris

 

Mount as :

 

mount /dev/nbd0p1 /mnt/q

root@occi:~# df

Filesystem     1K-blocks    Used Available Use% Mounted on

/dev/md0        34504456 7504564  25270464  23% /

udev             4078416       4   4078412   1% /dev

tmpfs            1635552     248   1635304   1% /run

none                5120       0      5120   0% /run/lock

none             4088876       0   4088876   0% /run/shm

/dev/nbd0p1      6342760 1487020   4533540  25% /mnt/q

root@occi:~# cd /mnt/q

root@occi:/mnt/q# ls

bin  boot  dev  etc  home  initrd.img  lib  lib32  lib64  lost+found  media  mnt  opt  proc  root  sbin  selinux  srv  sys  tmp  usr  var  vmlinuz

—————————————-

To disconnect use

umount  /mnt/q

root@occi:~# qemu-nbd -d /dev/nbd0