
You should change this number according to your computer’s CPU. We chose to use 3 cores to run the virtual image which will make it faster.
-smp 3: If we want to use more than 1 core for the emulated operating system, we can use this option. That’s why we must use this option, just make sure that the virtualization options are enabled from your computer BIOS. Without it, QEMU will use software rendering which is very slow. It allows us to use the KVM technology to emulate the architecture we want. -enable-kvm: This is a very important option. You can use -c if you want to boot the hard drive image first. We have used the -cdrom option as you can see at the end of the command. -boot -d: The boot option allows us to specify the boot order, which device should be booted first? -d means that the CD-ROM will be the first, then QEMU will boot normally to the hard drive image. You can change it if you like according to your needs. -m 1024: Here we chose the RAM amount that we want to provide for QEMU when running the ISO file. Let’s explain the previous command part by part: Now that we’ve created our image file, if we have an ISO file for a Linux distribution or any other operating system and we want to test it using QEMU and use the new image file we created as a hard drive, we can run: qemu-system-x86_64 -m 1024 -boot d -enable-kvm -smp 3 -net nic -net user -hda testing-image.img -cdrom ubuntu-16.04.iso Note also that the size of this file is not 10 Gigabytes, it’s around 150KB only QEMU won’t use any space unless needed by the virtual operating system, but it will set the maximum allowed space for that image to 10 Gigabytes only Note that a new file called “testing-image.img” is now created at your home folder (or the place where you run the terminal).
To create an image file with the size of 10GB and qcow2 format (default format for QEMU images), run: qemu-img create -f qcow2 testing-image.img 10G
To do this, we can use the “qemu-img” tool. This image file will contain all the data and files of the operating system after installation.
And we’ll see many different examples in order to understand the possible ways to achieve our goals using QEMU.įirst, we have to create a virtual hard drive image if we want to install our virtual operating system somewhere. QEMU provides a lot of options, architectures and formats to use. To install QEMU on Arch Linux: sudo pacman -S qemu How To Use QEMU To install QEMU on SUSE/openSUSE sudo zypper in qemu To install QEMU on Red Hat/CentOS/Fedora (replace dnf with yum for Red Hat/CentOS): sudo dnf install qemu qemu-kvm To install QEMU on Ubuntu/Linux Mint: sudo apt install qemu qemu-kvm Which is a good thing for us since we won’t need to download or install anything from 3rd party repositories. Fortunately, QEMU is available to install from almost all the official Linux distributions repositories.