简体   繁体   English

如何保留 QEMU VM 镜像中的更改?

[英]How to retain the changes in the QEMU VM image?

I want to use QEMU to emulate Linux OS and create a Virtual Machine (VM) for Tiny Core Linux (TCL) .我想使用 QEMU 来模拟 Linux 操作系统并为Tiny Core Linux (TCL) 创建一个虚拟机 (VM) I used the following commands the run TCL VM via QEMU.我使用以下命令通过 QEMU 运行 TCL VM。

First, I created a VM image in qcow2 format (I also tried to create .img image but it seems to have the same effect).:首先,我创建了一个 qcow2 格式的 VM 镜像(我也尝试创建.img镜像,但它似乎有相同的效果):

qemu-img create -f qcow2 TCLcoredisk.qcow2 1G

Then, I booted the TCL by QEMU emulator.然后,我通过 QEMU 模拟器启动 TCL。 It works well, and I can do some operations in the VM (eg, create a new directory and file, mount a file system).它运行良好,我可以在 VM 中执行一些操作(例如,创建新的目录和文件,挂载文件系统)。

qemu-system-x86_64 -boot d \
    -cdrom Core-current.iso \
    -m 500 \
    -hda TCLcoredisk.qcow2 \
    -nographic \
    -enable-kvm \
    -curses

The issue was that after I shut down the QEMU (pkill the QEMU process), I cannot retain the changes I made by booting the previous image file.问题是,在我关闭 QEMU(pkill QEMU 进程)后,我无法保留通过启动之前的映像文件所做的更改。 Worse, I cannot even boot the image.更糟糕的是,我什至无法启动映像。 I can only boot by -cdrom with the .iso image file but changes will be lost.我只能使用.iso映像文件通过-cdrom启动,但更改将会丢失。 However, as I mounted a file system on a newly-created directory during the first boot, all the information of first booting was lost if I boot the TCLcoredisk.qcow2 image file again.但是,由于我在第一次启动时挂载了文件系统到新建的目录中,所以再次启动TCLcoredisk.qcow2镜像文件时,第一次启动的所有信息都丢失了。 I used the following command to boot this existing image file:我使用以下命令来启动这个现有的映像文件:

qemu-system-x86_64 -drive "file=TCLcoredisk.qcow2,format=qcow2" \
    -m 500 \
    -nographic \ 
    -enable-kvm \
    -curses

I got the error Nothing to boot: No such file or directory (http://ipxe.org/2d03e13b) .我收到错误Nothing to boot: No such file or directory (http://ipxe.org/2d03e13b) My host machine only supports command line without using graphical interfaces, that is why I used -nographic and -curses .我的主机只支持命令行而不使用图形界面,这就是我使用-nographic-curses的原因。 I also want to use TCL only by command line.我也想只通过命令行使用 TCL。 I guess I don't need to use the .iso image file anymore after the first boot.我想在第一次启动后我不需要再使用.iso映像文件了。 Is there a way that I can boot the existing image file properly and retain the changes in the previous booting?有没有办法可以正确启动现有的映像文件并保留以前启动时的更改? Thank you!谢谢你!

It was pointed that on FAQ Tiny Core Linux only bases on RAM.有人指出,在 FAQ 上,Tiny Core Linux 仅基于 RAM。 Thus you cannot use a persistent filesystem因此你不能使用持久文件系统

What is the boot architecture?引导架构是什么?

Tinycore always boots to ram. Tinycore 总是启动到 ram。 This unique way has several advantages, like 100% functioning usb boot, awesome speed, and being able to boot without having the ability to access the boot device after booting.这种独特的方式有几个优点,比如 usb 启动 100% 正常运行,速度惊人,并且能够在启动后无需访问启动设备的情况下启动。 You're free to snag out the usb drive right after initrd is loaded, for example.例如,您可以在加载 initrd 后立即取出 usb 驱动器。 https://distro.ibiblio.org/tinycorelinux/faq.html#arch https://distro.ibiblio.org/tinycorelinux/faq.html#arch

You will need to use another distribution您将需要使用其他发行版

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM