0

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!

Jeffrey
  • 59
  • 1
  • 5
  • 1
    The next boot should be `-boot c` booting from the harddisk instead of `boot -d`. Can you try it ?? – nhatnq Sep 28 '21 at 07:39
  • @nhatnq Thanks. I tried using `-boot c` but it still had the same error `Nothing to boot: No such file or directory (http://ipxe.org/2d03e13b)` and `No bootable device.` I wonder if there is a way to check whether the OS and my changes had been written into the image file. I am not sure if the issue was from the image file or the wrong command. Should the next boot command include network configurations and/or other configurations? – Jeffrey Sep 28 '21 at 16:02

1 Answers1

1

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

nhatnq
  • 1,173
  • 7
  • 16
  • Thanks. Great point. Is there a way for QEMU to handle this case (i.e., persist RAM-based OS)? – Jeffrey Sep 29 '21 at 18:22
  • 1
    @Jeffrey I think no unless you can try another distribution which supports disk spaces e.g Ubuntu, Fedora. Alpine is also a choice for lightweight – nhatnq Sep 30 '21 at 02:56