Creating an Ubuntu Virtual Machine
- Download Ubuntu server 16.04 LTS or 18.04 LTS:
- Use virt-manager on a Linux system to create a VM with 2 CPUs, 4 GB RAM and 32 GB hard disk of qcow2 format. Select the option customize configuration before install.
- Customize the configuration to change the hard disk bus type to VirtIO.
- Start the VM.
- Follow the prompts to complete the Ubuntu installation.
-
Enable the serial console:
-
Edit the file /etc/default/grub to have the
following settings:
GRUB_CMDLINE_LINUX="console=tty1 console=ttyS0,115200" GRUB_TERMINAL="console serial" GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
- Update /boot/grub/grub.cfg: update-grub.
-
Edit the file /etc/default/grub to have the
following settings:
-
(Optional) Update the system and
install additional software:
-
Enable all repositories
for apt:
- apt-add-repository restricted
- apt-add-repository universe
- apt-add-repository multiverse
- apt update
- Upgrade Ubuntu and software: apt upgrade.
- Reboot if required.
-
Install additional
software:
- apt install build-essential
- apt install checkinstall
- apt install iperf apt install mtools
- apt install netperf
- apt install qemu-guest-agent
- apt install tshark
- apt install valgrind
- apt install vim-gnome
- apt install wireshark
- apt install xterm
-
Enable all repositories
for apt:
-
Fill the unused disk space with zeros so that the image interacts well with
compression: dd if=/dev/zero of=/mytempfile (will
eventually error out with 'out of space', but may take a while):
rm -f /mytempfile
- Shutdown the VM.
-
Copy the qcow2 disk image onto an ExtremeXOSswitch and
install it as a VM. The image is located at
/var/lib/libvirt/images/.
Note
If you do not have root access, you the following command to create a copy of the disk image: virsh vol-download --pool default disk_name.qcow2 my_copy.qcow2.Note
The image size can be reduced substantially because of all the adjacent zeroes: qemu-img convert -O qcow2 my_copy.qcow2 my_reduced_copy.qcow2.