VM: QEMU: Installing Kali Linux into a Headless Server

In this guide we install Kali into a VM inside QEMU (Quick Emulator)!

VM: QEMU: Installing Kali Linux into a Headless Server

QEMU or 'Quick Emulator' knocks it out of the park in comparison to crippled VM options such as VirtualBox.  Grant you to use QEMU you will need to get to the Linux operating system to start.

What not everyone is familiar with is that auto-completion is available for apt installation. Such as:

sudo apt install libvirt-<tab><tab>
sudo apt install qemu-kvm virt-manager virtinst libvirt-clients bridge-utils libvirt-daemon-system -y

Now we enable the libvrtd system:

sudo systemctl enable --now libvirtd
sudo systemctl start libvirtd

After this point we want to make two types of scripts

  • One that loads the CDROM iso image  and hard drive for the installation.
  • One that loads just the hard drive for regular running.

Kali Linux is a very powerful  fast pentesting operating system based off of Ubuntu.    Considering it also includes a pile of pen testing tools and how clean its interface is.

Now we want to make a hard drive for the VM to utilize with the command:

qemu-img create disk.img 60G

60G - create a 60 Gigabyte drive.  On a nvme drive this is almost instant.

Because we are working with a headless motherboard we need to prove that we have X-11 working ssh in with a -X (or -Y) option:

ssh -X user@192.168.2.100

Running our image:

qemu-system-x86_64 -boot d -cdrom kali.iso -m 6G -hda disk.img

It will create a installation window:

Using linux utility htop we can see it is minimal loading on the CPU:

Specifying the CPU option and putting this into a simple boot.sh script:

In this option our Ryzen 2600 is a 6 core - 12 thread, and as far as we are concerned it equals a maximum option of 12 core for the command line.  Because we do not want to kill or choke the main system we give it an ample 6 cores with maximum 10 as required. That leaves a few extra cores.

  • Additionally we must make a virtual sound card for this:
qemu-system-x86_64 -boot d -cdrom kali.iso -m 8G -drive format=raw,file=disk.img -smp 6,maxcpus=10 -audiodev alsa,id=my_audio
chmod +x boot.sh

chmod (change mode) with +x will make the script (boot.sh) executable. Because boot.sh is not in the $PATH we can still call it with ./boot.sh

We can now see that qemu is allocating a lot of threads to this VM and it runs appreciably (and usably faster)

Select your language / location etc.

Kali will scan your virtual CDROM and virtual 60GB hard drive. Nice.

Linux Rocks Every Day