Jeffrey
Jeffrey

Reputation: 59

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). I used the following commands the run TCL VM via QEMU.

First, I created a VM image in qcow2 format (I also tried to create .img image but it seems to have the same effect).:

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

Then, I booted the TCL by QEMU emulator. It works well, and I can do some operations in the VM (e.g., create a new directory and file, mount a file system).

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. Worse, I cannot even boot the image. I can only boot by -cdrom with the .iso image file but changes will be lost. 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. 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). My host machine only supports command line without using graphical interfaces, that is why I used -nographic and -curses. I also want to use TCL only by command line. I guess I don't need to use the .iso image file anymore after the first boot. Is there a way that I can boot the existing image file properly and retain the changes in the previous booting? Thank you!

Upvotes: 0

Views: 1985

Answers (1)

nhatnq
nhatnq

Reputation: 1193

It was pointed that on FAQ Tiny Core Linux only bases on RAM. Thus you cannot use a persistent filesystem

What is the boot architecture?

Tinycore always boots to 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. You're free to snag out the usb drive right after initrd is loaded, for example. https://distro.ibiblio.org/tinycorelinux/faq.html#arch

You will need to use another distribution

Upvotes: 1

Related Questions