运行 Windows XP 的 KVM 虚拟机:如何将文件从来宾获取到主机?
我正在运行 Ubuntu 10.04,并在其上运行 kvm/qemu。我创建了一个“raw”格式的存储设备并在其上安装了XP,所以我假设该文件具有ntfs格式。我在XP虚拟机上有一个我想要在主机上的文件。它有 2gig,所以我不能只使用 zip 驱动器或将其刻录到 CD。
我尝试使用 losetup 挂载文件(winxp.img
):
$ sudo losetup /dev/loop1 winxp.img
$ sudo losetup -a
/dev/loop1: [0801]:40637460 (/home/robert/kvm/images/winxp.img)
$ sudo mount -t ntfs /dev/loop1 /home/robert/kvm/images/tmp
NTFS signature is missing.
Failed to mount '/dev/loop1': Invalid argument
The device '/dev/loop1' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
我认为这可行。事实并非如此。还有人有其他想法吗?
I'm running Ubuntu 10.04, and on it, kvm/qemu. I created a storage device with the 'raw' format and installed XP on it, so I assume the file has ntfs format. I have a file on the XP virtual machine that I want on the host. It's 2gigs, so I can't just use a zip drive or burn it to CD.
I tried mounting the file (winxp.img
) using losetup:
$ sudo losetup /dev/loop1 winxp.img
$ sudo losetup -a
/dev/loop1: [0801]:40637460 (/home/robert/kvm/images/winxp.img)
$ sudo mount -t ntfs /dev/loop1 /home/robert/kvm/images/tmp
NTFS signature is missing.
Failed to mount '/dev/loop1': Invalid argument
The device '/dev/loop1' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
I thought that would work. It didn't. Does anyone have another idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
winxp.img和loop1不是单个分区(可以挂载),它是带有自己分区表的完整硬盘的映像。
您应该使用 fdisk 从 Loop1 读取分区表;计算第一个分区的偏移量并执行以下操作:
其中 N 是以字节为单位的偏移量。
心灵感应模式开启
N 是 32256
关闭心灵感应模式
,最后打开谷歌模式(我将谷歌搜索“offset 32256”):
http://en.wikibooks.org/wiki/QEMU/Images#Mounting_an_image_on_the_host
winxp.img and loop1 is not a single partition (which can be mounted), it is image of full hard disk with own partition table.
You should read partition table from loop1 with fdisk; compute offset of first partition and do:
where N is offset in bytes.
Telepathic mode on
N is 32256
Telepathic mode off
and finally, google mode on (I'll google "offset 32256"):
http://en.wikibooks.org/wiki/QEMU/Images#Mounting_an_image_on_the_host
在我看来,通用且正确的方法是通过 libguestfs http://libguestfs.org/
如果你掌握了它,你可以打开任何格式的每个虚拟映像并获取文件甚至制作快照
In my opinion the generic and correct way is via libguestfs http://libguestfs.org/
If you master it, you can open every virtual image in any format and get files or even make snapshots