Coding with Titans

so breaking things happens constantly, but never on purpose

Install Ubuntu Server 19.04 on Windows 10 Hyper-V

I am a really trouble guy and having problems and spending sleepless nights seems quite often to me. But gee, it’s 2019! and still it’s not very obvious, why sometimes it’s so hard to do things that in theory should be so easy.

You probably noticed, that I like TeamCity. Since I am going to participate in JetBrain’s latest TeamCity Plugin Contest 2019 I came up with idea of setting up virtual machine with a test instance of the CI, instead of messing up my production one to only test the plugin. I choose latest Ubuntu Server to minimize resources required. I created new Hyper-V machine Gen 2, inserted ISO into the virtual DVD drive and all collapsed.

So for future reference, not to forget and also achieve it quicker, below I present a small guide, how to initialize Ubuntu Server under Hyper-V control. Refer to my previous post, if for any reason you use HAXM or QEMU and don’t know how to enable Hyper-V.

  • First, you need the “traditional installer”. If you choose the “live-server installer” (default one), later during the process, console tty1 will continuously fail with and exception and won’t let installation to finish.

download-ubuntu-server

  • Make sure that Hyper-V has defined a network switch with access to the Internet. If doesn’t have one, just create a new as shown below to avoid some warnings during the installation.

external-network

  • Manually create a hard-drive for the virtual machine. To do it, use the following PowerShell command:
New-VHD -Path 'H:\Virtual Machines\Ubuntu-Server\Ubuntu-Server.vhdx' -SizeBytes 64GB -Dynamic -BlockSizeBytes 1MB

It will more effectively use hard-disk on the host side as by default the block-size is 32MB. That means VHDX allocates space in 32MB chunks even if guest OS only wants to write 512kB at random locations. More info here.

  • Finally – create the virtual machine itself with “ubuntu-19.04-server-amd64.iso” mounted as DVD drive.

However are few pitfalls:

  1. use at least 2 CPU cores and enough RAM
  2. switch to Microsoft UEFI certificate authority (default one is only suitable for Windows UEFI installations); without that UEFI will report invalid OS
  3. use previously crated VHD
  4. use network switch with Internet access
  5. make sure, that manually created DVD drive is first during the boot sequence and points to proper Ubuntu Server ISO file

create-ubuntu-vm

That’s all. Run the machine. Proceed with installation and have fun!