TinyCoreLinux is handy for various tasks. I use the dCore variant because it can use many of the packages from Debian.
Qemu is especially useful because it is portable (can run off a USB flash drive) and there are versions for multiple host OS's (eg. Windows, Linux). The downside is that it's a bit slow under Windows - it needs a suitable driver to use hardware virtualisation, and there doesn't seem to be one for Windows hosts - still, it is fast enough to be useful.
This document was tested with the 25-May-2016 (v7.0?) release of dCore TinyCoreLinux, running under Qemu v2.5.0 on Windows 7 (64-bit).
Download TinyCoreLinux
Create a new directory for your VM - for this document I have used C:\dCore
As at time of writing, the download directory for dCore Jessie is http://tinycorelinux.net/dCore/x86/release/dCore-jessie
If that directory does not work, start at http://tinycorelinux.net, click "Downloads" (at top of page), then "Other Ports (x86-64, dCore, & Raspberry Pi)", then "Releases" in the "dCore x86" section, then "dCore-jessie"
Download these files and put them in C:\dCore
:
dCore-jessie.gz
vmlinuz-jessie
Note that windows will probably rename the kernel from vmlinuz-jessie
to vmlinuz-jessie.txt
- you should rename it back to vmlinuz-jessie
after download. If you've got file extensions turned off in Windows Explorer, then this will be inconvenient, and it's probably less effort to edit the launcher script to include the .txt
even though the kernel is not a text file.
If you're being thorough, download the "md5" files and use them to check the integrity of the files.
Download Qemu
I use the build of qemu found at http://lassauge.free.fr/qemu
Download Qemu-2.5.0-windows.7z
and extract it into C:\dCore
- this will create a directory C:\dCore\Qemu-windows-2.5.0
containing the various qemu exe files and DLLs, etc.
Create empty disk image
We need to create a virtual hard drive to store persistent files in. Open a command prompt in C:\dCore
and run the following qemu-img
command (you may want to specify a size different than 4G, depending on requirements):
C:\dCore> Qemu-windows-2.5.0\qemu-img.exe create -f qcow2 sda.qcow2 4G
Formatting 'sda.qcow2', fmt=qcow2 size=4294967296 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16
Close the command prompt window.
Create launcher script
Create a batch file "C:\dCore\go.cmd
" and edit it to contain (or download):
@echo off
:: cd into the directory where our files are
cd /d %~dp0
:: define where qemu is
set QEMUDIR=.\Qemu-windows-2.5.0
set QEMUEXE=qemu-system-x86_64w.exe
start /b %QEMUDIR%\%QEMUEXE% ^
-L %QEMUDIR%\bios ^
-kernel vmlinuz-jessie ^
-initrd dCore-jessie.gz ^
-append " noswap tce=sda opt=sda home=sda showapps host=dcore xvesa=800x600x24 " ^
-hda sda.qcow2 ^
-k en-us ^
-display gtk ^
-m 512M ^
-name "dCore_x86_SSH22022" ^
-redir tcp:22022::22
Note: There can be no spaces at the end of the lines after ^
Things you might want/need to edit:
QEMUDIR
- if you're using a different version of qemu, or have saved it somewhere else.QEMUEXE
- if you're not using 64-bit windows then you probably needqemu-system-i386.exe
- the name of the
kernel
/initrd
if you've got a newer release of dCore than Jessie, or they have different names (like an unwanted.txt
extension). - change the
-k
line to change the keyboard layout - you can see the valid options inC:\dCore\Qemu-windows-2.5.0\Bios\keymaps
- change the
-m
line to change the amount of memory allocated to the VM. - change the window title with the
-name
line. - change the
-redir
line to alter port-forwarding - the line shown above redirects port 22022 on the host machine (your Windows computer) to port 22 inside the VM. This is no use right now, but will be useful if you install SSH inside the VM. - in the
-append
line you can setup kernel command-line options.host=dcore
sets the hostname of the VM.xvesa=800x600x24
sets the VM display resolution.
Check
Just as a cross-check of the above instructions, this is what my directory contains:
C:\dCore> dir
Volume in drive C has no label.
Volume Serial Number is DEAD-BEEF
Directory of C:\dCore
2016-06-24 04:43 pm. <DIR> .
2016-06-24 04:43 pm. <DIR> ..
2016-06-24 04:35 pm. <DIR> Qemu-windows-2.5.0
2016-06-24 04:19 pm. 13,400,343 dCore-jessie.gz
2016-06-24 04:42 pm. 583 go.cmd
2016-06-24 04:40 pm. 197,120 sda.qcow2
2016-06-24 04:17 pm. 3,465,360 vmlinuz-jessie
4 File(s) 17,063,406 bytes
3 Dir(s) 26,287,616 bytes free
First boot, and format virtual HDD
Double-click on go.cmd
and wait for it to boot (takes about 30s on my machine). Note that the boot process is a little "messy" - you may have some messages appearing over the top of console. There are also error messages regarding the floppy drive (fd0), since it doesn't exist.
Wait for it to stop printing things, then press [Enter]
a few times to get a clean prompt.
On a normal system, we'd partition the HDD and install a bootloader - this is not necessary here because we have our kernel/initrd supplied externally to the VM. We create a filesystem directly on /dev/sda
instead of the more usual /dev/sda1
Run the following (ignore the harmless partition table warning):
tc@dcore:~$ sudo mkfs.ext4 -L dcore /dev/sda
mke2fs 1.42.12 (29-Aug-2014)
Discarding device blocks: done
Creating filesystem with 1048576 4k block and 262144 inodes
Filesystem UUID: 20c4682a-98b3-4fd6-9105-10f44228b7f2
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
sda: unknown partition table
Reboot and test
Click in the qemu window and run the following:
tc@dcore:~$ exitcheck reboot
The VM will now reboot. Wait for it to start up and then have a look at the sda mountpoint:
tc@dcore:~$ ls /mnt/sda
home/ lost+found/ opt/ tce/
You should see that TinyCoreLinux has created the home
, opt
, and tce
directories. If you create some SCE files (with sce-import
), for example, they will be stored in /mnt/sda/tce/sce/
Similarly, your home folder files (for the default user "tc
") will be stored in /mnt/sda/home/tc/
References
- Qemu comes with a help file - refer to
C:\dCore\Qemu-windows-2.5.0\Doc\qemu-doc.html
or find online qemu docs at http://wiki.qemu.org/Manual - http://wiki.tinycorelinux.net/wiki:start
- http://wiki.tinycorelinux.net/dcore:welcome