Using QEMU in Linux Debian 9 Stretch, another alternative to Virtual Machines.
QEMU, Is a powerful alternative to VMWare and Oracle Virtualbox, to make a virtual machine inside your PC, that allows you to run some other OS's and architectures inside your Linux Operative System. You can emulate IA-32, X86-64, MIPS, Power PC and some other architectures, whithout turning off your main operative system.
In this time we are about to use QEMU as a system emulator; It will let us emulate a whole computer including their own peripheral.
Installing QEMU
QEMU package is normally inside the Debian repositories, but if you don't find it as is used to be, you may need to visit the debian official page to download it: https://www.qemu.org/download/. Well, let's install using the command apt-get as a sudo user in the Linux console, but first, make an update and then an upgrade to your Linux packages:
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install qemu
Once installed lets get some tips to use it!.
Start Using QEMU
QEMU will let you create a virtual machine that will take some of the RAM memory and Hard drive space from your PC. It will let you use all the peripherals that the host machine have.
How can you handle the fact that the virtual machine and the host machine runs in the same space?. Well, for default conditions QEMU will run in a new Window that will be created at the same time you run the code. You can make click inside this window and then, the mouse pointer will be catched inside the virtual machine, and then you can use this new virtual OS as if you were using your host PC. If you want to return to the host, you must push Ctrl+Alt together on your keyboard.
It is recommended using QEMU in root mode, or just using the sudo command before every command that you write, specially when you want to access peripherals from the host PC.
QEMU Sintax:
$ sudo qemu-system-i386 [options] [disk_image] (for i386 based Systems)
or
$ sudo qemu-system-x86_64 [options] [disk_image] (for x86_64 based Systems)
Testing an ISO image
If you want to test any ISO image, You must run this code:
$ sudo qemu-system-i386 -m 512 -cdrom [ISO_name].iso (for i386 platforms)
or
$ sudo qemu-system-x86_64 -m 512 -cdrom [ISO_name].iso (for 64 bits platforms)
Where:
| m | Defines the amount of memory that QEMU will take from the host PC, in this example the amount of memory is 512MB. If you don't specify this parameter, it will take 128MB by default. Do not try to take more memory that your host will let you, because it can make a crash in your host. |
|---|---|
| cdrom | This parameter defines [ISO_name].iso as the tested CDROM ISO |
And then QEMU will run that ISO in a new window.For instance, Here are an image where I am testing Linux Austrumi
with QEMU:
Steps to Create and Install a new Virtual Machine.
This steps will let you create a new virtual machine in your hard drive. In this example, I am going to install
Puppy Linux Slacko distro on this machine,
- Create a new image to install the new operative system in your hard disk. Some people are used to get an external hard drive to install the new OS. It must be created with this command:
$ sudo qemu-img create [image_name].img [size_of_hdd]
Where:
| [image_name] | will be the name of the image wich will receive your brand new OS. |
|---|---|
| [size_of_hdd] | Is the size of hard drive space that will be reserved for the new OS |
E.g.:
$ sudo qemu-img create slacko.img 10G
As you can see the size of slacko.img has been expressed in G(giga).
- Now you can install the new OS in your new image. In order to install the new OS, you must have the respective ISO installer and then mount it in your new image, to start the respective installation. It will be mounted as if you had used a CD to install a new OS. So this is the sintax:
$ sudo qemu-system-i386 -hda slacko.img -cdrom slacko-5.3.3-4g-SCSI.iso -boot d -m 1024
Where:
| -hda | Is the main image unit where the ISO will run. |
|---|---|
| -cdrom | This parameter indicates that slacko-5.3.3-4g-SCSI.iso, is a CDROM ISO that will run in the image slacko.img. |
| -boot d | Indicates wich device will be the main boot device. It can be: "a" If you are using a floppy disk, "b" a hard drive, "d"A CDROM, "n" a Network location where the ISO could be located. |
And now a new window will appear, and you can start, the installation of the OS in the virtual machine. The more memory you take from the host, the faster the installation will go. Once you finished the proccess of installation, the new machine will be ready to be used!.
- Just run your brand new virtual machine with your new OS inside:
$ sudo qemu-system-i386 -hda slacko.img -m 1024
The ISO's that we used in this article you can find it here:
Linux Austrumi ==> https://cyti.latgola.lv/ruuni/
Linux Puppy ==>https://puppylinux.com/
Well that's all for now. It will be a second article to explaining how to use peripherals inside the virtual machine. So thanks for reading!, and see you on next time.