英文:
Is it possible to convert a machine image to raw and pipe to `dd` at same time?
问题
首先,一些背景信息:
我被指派创建一种方法来启动、配置和保存一个虚拟机,以一种可以在物理硬盘上使用的格式。我使用了Vagrant、Packer和VirtualBox来完成这个任务。
问题是,为了在真实的硬盘上使用它,输出的.vmdk
文件需要转换为原始格式,并使用dd
实用程序写入硬盘。原始格式相当大,因为在这种格式中没有缩短空白空间;它的大小与生成时的文件系统大小完全一样。
是否可能将.vmdk
镜像转换为原始格式并通过dd
管道传输到写入者的文件系统而不会扩展它?
我尝试搜索任何现有的解决方案,但没有找到太多信息。我猜想这可能是不可能的。
英文:
First off, some background:
I was tasked with creating a way to boot, configure, and save a virtual machine in a format that can be used on a physical hard drive. I accomplished this with Vagrant, Packer, and VirtualBox.
The problem is that in order to use it on a real hard drive, the output .vmdk
needs to be converted to a raw format and written to the hard drive with the dd
utility. The raw format is quite large because there's no shortening of empty space in this format; it's exactly as large as the file system is when it gets generated.
Is it possible to convert the .vmdk
image to raw and pipe it to dd
without expanding it on the writer's file system?
I've tried looking around for any existing solutions, but haven't come up with much. My guess is it's not possible.
答案1
得分: 1
以下是已翻译的内容:
对于可能遇到这个问题的其他人,解决方法如下:
qemu-img
实用程序内置了此功能,带有 dd
选项。
该命令基本上是将 dd
语法附加到 qemu-img
实用程序参数的末尾。
例如:qemu-img dd -f vmdk -O raw if=your-image.vmdk of=/dev/sda bs=16M status=progress
。
英文:
For anyone else that might come across this, the solution was (as usual) to RTFM
The qemu-img
utility has this functionality built into it, with a dd
option.
The command is pretty much the syntax of dd
tacked onto the end of the qemu-img
utility parameters.
E.g. qemu-img dd -f vmdk -O raw if=your-image.vmdk of=/dev/sda bs=16M status=progress
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论