运行 Windows XP 的 KVM 虚拟机:如何将文件从来宾获取到主机?

发布于 2024-12-16 21:03:18 字数 695 浏览 2 评论 0原文

我正在运行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

美胚控场 2024-12-23 21:03:18

winxp.img和loop1不是单个分区(可以挂载),它是带有自己分区表的完整硬盘的映像。

您应该使用 fdisk 从 Loop1 读取分区表;计算第一个分区的偏移量并执行以下操作:

sudo mount -o offset=N -t ntfs /dev/loop1 /home/robert/kvm/images/tmp

其中 N 是以字节为单位的偏移量。

心灵感应模式开启
N 是 32256
关闭心灵感应模式

,最后打开谷歌模式(我将谷歌搜索“offset 32​​256”):

http://en.wikibooks.org/wiki/QEMU/Images#Mounting_an_image_on_the_host

Linux 和其他类 Unix 主机可以使用环回设备挂载使用原始格式类型创建的映像。从 root 登录(或使用 sudo),安装偏移量为 32,256 的环回。

mount -o循环,offset=32256 /path/to/image.img /mnt/mountpoint

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:

sudo mount -o offset=N -t ntfs /dev/loop1 /home/robert/kvm/images/tmp

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

Linux and other Unix-like hosts can mount images created with the raw format type using a loopback device. From a root login (or using sudo), mount a loopback with an offset of 32,256.

mount -o loop,offset=32256 /path/to/image.img /mnt/mountpoint

樱娆 2024-12-23 21:03:18

在我看来,通用且正确的方法是通过 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文