Creating A VM without VirtualBox and VMware!
Miscellaneous 0x1
Two roads diverged in a wood, and I —
I took the one less traveled by,
And that has made all the difference.
-Robert Frost
Hello explorer! Today I will guide you through a less known path for creating a guest virtual machine on Linux/Windows/Mac. In this story I will talk about my journey from VirtualBox -> VMware -> Qemu. There is a very less chance that you’ve ever heard about Qemu as it a command line tool and is super lightweight! and also super easy! ( As compared to VBox and VMware ).
Ok, so long story short : I switched to Qemu as you can start your VM with a single command and also there is very less ram and cpu usage as compared to VBox and VMware. I can execute VMs as small as a bootloader! And finally it’s open source
Go to this link to visit the above page, then navigate to the download section and download it for your respective platform! If you are on Linux then you can just use your packet manager to install it!
To start with, we need a virtual hardrive on which we will install an OS, for that we can do : qemu-img create virtual-hdd.img -f qcow2 16G
. This will create an img file in your current directory named virtual-hdd.img
with qcow2 format and of size 16 GiB, but the actual file size right now will be in KiBs’! You can use qemu-img info virtual-hdd.img
to get the complete information about the virtual image we just created!
Now, I am an Arch Linux lover so, I will boot that to install it on my virtual-hdd.img
. You can boot your favorite linux/windows/any other OS, but the command to do that will remain same. Let’s say, the name of Arch Linux live ISO file is arch.iso
, then execute the following command : qemu-system-x86-64 -hda virtual-hdd.img -smp 2 -m 1024 -cdrom arch.iso -boot d
This command will use virtual-hdd.img
as the hard disk and arch.iso as cdrom, also -smp 2
specifies the number of cores to be 2 ( this value must not exceed number of cores on your machine ) and -m 1024
specifies the RAM size to be 1024 MiB. The -boot d
parameter specifies the qemu-system to set the boot priority of cdrom to be maximum and -hda
parameter is used to give the location of virtual-hdd file. This will boot the arch linux live os and then you can perform the regular install. So, basically you had to execute only two commands out of which only one is to be used everytime you need to install an OS. Let’s say you needed to set the boot priority to hard drive then you’d use -boot c
instead of -boot d
.
Wait for it to boot!
To check the connection to the internet , use ping www.google.com -c 4
or wget google.com
. If either of them works then you are connected to the internet!
If you are still facing some problems then that’s for another story! You can mention your problems in the comments! ;-)
After you installed the guest VM and now you just want a normal boot, you can use the command qemu-system-x86-64 -hda virtual-hdd.img -m 1024
. You can specify the -smp
option if you want!
r00t3r signing off till next post…