LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization
User Name
Password
Linux - Virtualization This forum is for the discussion of all topics relating to Linux Virtualization. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices

Reply
 
LinkBack Search this Thread
Old 02-07-2010, 07:37 AM   #1
hrmb
LQ Newbie
 
Registered: Oct 2009
Posts: 12

Rep: Reputation: 0
Unhappy how to mount a kvm image file


Hi

I am trying to mount a kvm image file (qcow format), I am using this method (http://equivocation.org/node/107), but it doesn't work for me!

please help me, it's urgent
 
Old 02-07-2010, 08:06 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Squeeze (Fluxbox WM)
Posts: 1,324
Blog Entries: 43

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Can you provide details about where the steps are failing, and what is the error output? Also, what distro are you running?

An alternative method would be to use qemu-img to convert it to a raw image, and then loop mount it (assuming you have the disk space).

Last edited by neonsignal; 02-07-2010 at 08:15 AM.
 
Old 02-08-2010, 02:22 AM   #3
hrmb
LQ Newbie
 
Registered: Oct 2009
Posts: 12

Original Poster
Rep: Reputation: 0
Angry

Hi,

I am using CentOS 5.4 and the third step dosen't work!!!

Quote:
[root@localhost mnt]# losetup -f
/dev/loop0
[root@localhost mnt]# losetup /dev/loop0 /root/Desktop/kvm-img/win7.img
[root@localhost mnt]# kpartx -av /dev/loop0
the kpartx dosen't show any thing, and furthur steps cause no result.
 
Old 02-08-2010, 07:12 AM   #4
dev_dks
LQ Newbie
 
Registered: Jul 2006
Location: INDIA
Distribution: RHEL/SOLARIS 10/UBUNTU/CENTOS
Posts: 13

Rep: Reputation: 1
Hi,

Instead of using losetup command, Just directly map the image file by using Kpartx command.

Skip losetup step.

Code:
kpartx -av "Path of image file"
 
To Unmap image

kpartx -dv "Path of image file"


Try it, May it will help you.



Dev
 
Old 02-10-2010, 11:41 AM   #5
dyasny
Member
 
Registered: Dec 2007
Location: Israel
Distribution: RHEL,Fedora
Posts: 457

Rep: Reputation: 54
This might work with the raw format. For qcow2, if you need to edit the disk, you need to use libguestfs.
 
Old 02-11-2010, 11:06 AM   #6
Chuck56
Member
 
Registered: Dec 2006
Location: Colorado
Distribution: Slackware
Posts: 394

Rep: Reputation: 57
To the best of my knowledge there is no way to loop mount a qcow or qcow2 disk image. There is a workaround with a raw disk image:

1) Convert your qcow2 to raw
Code:
root@name:/home# qemu-img convert -f qcow2 /home/your_current_image.qcow2 -O raw /home/your_new_image.raw
2) Find your physical hard disk block size:
Code:
root@name:/home# sfdisk -l

Disk /dev/sda: 19457 cylinders, 255 heads, 63 sectors/track
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sda1          0+  19456   19457- 156288321    5  Extended
/dev/sda2          0       -       0          0    0  Empty
/dev/sda3          0       -       0          0    0  Empty
/dev/sda4          0       -       0          0    0  Empty
/dev/sda5          0+    243     244-   1959867   82  Linux swap
/dev/sda6   *    244+   1217     974-   7823623+  83  Linux
/dev/sda7       1218+  19456   18239- 146504736   83  Linux
NOTE: This disk shows ", blocks of 1024 bytes,"

3) Issue the mount command with calculated offset:
Code:
root@name:/home# mount -o loop,offset=$((63*1024)) /home/your_new_image.raw /mnt/your_mount_point
or do the math manually: 63 * 1024 = 64512
Code:
root@name:/home# mount -o loop,offset=64512 /home/your_new_image.raw /mnt/your_mount_point
YMMV!

Last edited by Chuck56; 02-11-2010 at 11:08 AM. Reason: clarity
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I can't mount file system in a KVM quest hrmb Linux - Virtualization 5 11-02-2009 03:30 AM
can't mount the iso image file gbstack Linux - Newbie 3 09-06-2008 11:16 AM
make bootable CD from hard disk image and mount root file system as ramfs Mr.J Linux - Embedded 1 08-19-2008 08:29 AM
mount .iso (image) file and read *.avi file smartdragonfly Linux - Software 2 12-21-2006 05:48 AM
How to create a multi-file-image and mount it as a loopback device (on xbox debian) El_Oy Linux - Software 1 06-14-2006 03:05 AM


All times are GMT -5. The time now is 08:10 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration