VM: QEMU: Installing Ubuntu into a Headless Server

In this guide we install Ubuntu into a headless server inside QEMU

VM: QEMU: Installing Ubuntu 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.

Backbox is a very clean fast pentesting operating system based off of Ubuntu.    Considering it also includes a pile of pentesting tools and how clean its interface is it is the OS of choice.

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@

Running our image:

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

It will create a local 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 9 as required.

qemu-system-x86_64 -boot d -cdrom bb.iso -m 8G -drive format=raw,file=disk.img -smp 6,maxcpus=9
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)

Finally we also have a situation where our GPU is flanked out running.  Because of the latest features in QEMU - it can pass through the GPU card.  To disable this we add an option for a virtual VGA, and test:

-vga virtio

This does not make an appreciable increase in speed - taking it back off and just limiting the -smp=6 gives us a good working VM.

Linux Rocks Every Day