I use python-guestfs to mount windows image it have some problems .Here is my code: [root@mfsdata1 ~]# python Python 2.6.6 (r266:84292, Sep 11 2012, 08:34:23) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import os sheepfs_dir="/tmp/sheepfs" os.system("umount " + sheepfs_dir) 0 os.system("sheepfs -n " + sheepfs_dir) 0 vdi_name = "vm1935028.nbregion.ec2.cloudkc.cn" os.system("echo " + vdi_name + ">" + sheepfs_dir + "/vdi/mount") 0 import guestfs g=guestfs.GuestFS() imgfile=sheepfs_dir + "/volume/" + vdi_name g.add_drive_opts(imgfile, format="raw", readonly=0) g.launch() root = g.inspect_os() print root [] g.list_filesystems() [('/dev/vda1', 'ntfs'), ('/dev/vda2', 'ntfs')]
On Wed, Sep 04, 2013 at 02:31:08AM +0000, 徐展聪 wrote:
I use python-guestfs to mount windows image it have some problems .Here is my code:
[root@mfsdata1 ~]# python Python 2.6.6 (r266:84292, Sep 11 2012, 08:34:23) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import os sheepfs_dir="/tmp/sheepfs" os.system("umount " + sheepfs_dir) 0 os.system("sheepfs -n " + sheepfs_dir) 0 vdi_name = "vm1935028.nbregion.ec2.cloudkc.cn" os.system("echo " + vdi_name + ">" + sheepfs_dir + "/vdi/mount") 0 import guestfs g=guestfs.GuestFS() imgfile=sheepfs_dir + "/volume/" + vdi_name g.add_drive_opts(imgfile, format="raw", readonly=0) g.launch() root = g.inspect_os() print root []
So libguestfs can't find any guest(s) in the disk image. I suggest calling g.set_trace(1) after opening the handle, then looking at the trace output. If you can't see what is wrong, then post the full trace output on this list.
g.list_filesystems() [('/dev/vda1', 'ntfs'), ('/dev/vda2', 'ntfs')]
You can also just mount filesystems directly. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
g.inspect_os()
trace: libguestfs: trace: inspect_os libguestfs: trace: umount_all libguestfs: trace: umount_all = 0 libguestfs: trace: list_devices libguestfs: trace: list_devices = ["/dev/vda"] libguestfs: trace: vfs_type "/dev/vda" libguestfs: trace: vfs_type = "" libguestfs: trace: mount_ro "/dev/vda" "/" libguestfs: trace: mount_ro = -1 (error) libguestfs: trace: list_partitions libguestfs: trace: list_partitions = ["/dev/vda1", "/dev/vda2"] libguestfs: trace: vfs_type "/dev/vda1" libguestfs: trace: vfs_type = "ntfs" libguestfs: trace: mount_ro "/dev/vda1" "/" libguestfs: trace: mount_ro = -1 (error) libguestfs: trace: vfs_type "/dev/vda2" libguestfs: trace: vfs_type = "ntfs" libguestfs: trace: mount_ro "/dev/vda2" "/" libguestfs: trace: mount_ro = -1 (error) libguestfs: trace: list_md_devices libguestfs: trace: list_md_devices = [] libguestfs: trace: available "lvm2" libguestfs: trace: available = 0 libguestfs: trace: lvs libguestfs: trace: lvs = [] libguestfs: trace: inspect_os = [] [] ________________________________________ 发件人: Richard W.M. Jones [rjones@redhat.com] 发送时间: 2013年9月5日 16:13 收件人: 徐展聪 Cc: libguestfs@redhat.com 主题: Re: [Libguestfs] python-guestfs On Wed, Sep 04, 2013 at 02:31:08AM +0000, 徐展聪 wrote:
I use python-guestfs to mount windows image it have some problems .Here is my code:
[root@mfsdata1 ~]# python Python 2.6.6 (r266:84292, Sep 11 2012, 08:34:23) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import os sheepfs_dir="/tmp/sheepfs" os.system("umount " + sheepfs_dir) 0 os.system("sheepfs -n " + sheepfs_dir) 0 vdi_name = "vm1935028.nbregion.ec2.cloudkc.cn" os.system("echo " + vdi_name + ">" + sheepfs_dir + "/vdi/mount") 0 import guestfs g=guestfs.GuestFS() imgfile=sheepfs_dir + "/volume/" + vdi_name g.add_drive_opts(imgfile, format="raw", readonly=0) g.launch() root = g.inspect_os() print root []
So libguestfs can't find any guest(s) in the disk image. I suggest calling g.set_trace(1) after opening the handle, then looking at the trace output. If you can't see what is wrong, then post the full trace output on this list.
g.list_filesystems() [('/dev/vda1', 'ntfs'), ('/dev/vda2', 'ntfs')]
You can also just mount filesystems directly. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
On Fri, Sep 06, 2013 at 02:28:45AM +0000, 徐展聪 wrote:
libguestfs: trace: mount_ro "/dev/vda1" "/" libguestfs: trace: mount_ro = -1 (error) libguestfs: trace: vfs_type "/dev/vda2" libguestfs: trace: vfs_type = "ntfs" libguestfs: trace: mount_ro "/dev/vda2" "/" libguestfs: trace: mount_ro = -1 (error)
This is your problem. No NTFS partitions are mountable. It's likely that you don't have ntfs-3g installed or something like that. You should proceed to debug libguestfs as described in the FAQ: http://libguestfs.org/guestfs-faq.1.html#debug Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
participants (2)
-
Richard W.M. Jones -
徐展聪