Skip to content

Instantly share code, notes, and snippets.

@sye8
Last active July 8, 2021 18:13
Show Gist options
  • Save sye8/94caaeb8c6b26f38a99f3294653cfec6 to your computer and use it in GitHub Desktop.
Save sye8/94caaeb8c6b26f38a99f3294653cfec6 to your computer and use it in GitHub Desktop.
Creating an Ubuntu Virtual Machine in HyperV (Windows 10)

Creating an Ubuntu Virtual Machine in HyperV (Windows 10)

Last updated using Ubuntu 18.04.2 (amd64)

0. Pre-requisites

To check if your machine supports Hyper-V, fire up the Command Prompt (cmd.exe) and enter systeminfo.exe

At the end of the output, you will see an entry named Hyper-V Requirements.

If all you see are No, you need to enable hardware virtualization in BIOS. Otherwise, proceed

1. Enable Hyper-V

Open Windows Features (you can search for it in search box), check Hyper-V.

Click OK and wait for reboot

2. Get Ubuntu Image

You can find and download your favorite ubuntu release here

3. Create Virtual Machine

Open Hyper-V Manager (you can search for it in search box).

In Action menu, select New -> Virtual Machine...

hyperv1

Then, follow the wizard to create a virtual machine:

hyperv2

Very discriptive name

hyperv3

Use generation 1

hyperv4

2GB should be sufficient. Customize based on need and available system resources

hyperv5

We will configure network connection later

hyperv6

16GB should be sufficient for a guest OS. Customize based on need and available system resources

hyperv7

We will use the Ubuntu image you downloaded earlier to install OS

hyperv8

Looks right

hyperv9

Voilà!

hyperv10

4. First Boot

Double click on your newly created virtual machine.

Click start in the new window to fire it up, and you shall be welcomed by Ubuntu:

hyperv11

Select install and follow the guide

ubuntu1

Whatever keyboard you use...

ubuntu2

Basic or FULL DELUXE VERSION ?

ubuntu3

And yes we are going to erase disk for re-formatting. We are in a new virtual realm so there is nothing to wipe really.

ubuntu4

Continue

ubuntu5

Where am I?

ubuntu6

Who am I?

ubuntu7

Almost there, just restart

ubuntu8

NOTE: If virtual machine is stuck on prompt to remove disk and reboot, just Turn Off... the virtual machine in Hyper-V manager and start it again

YAY! ✧◝(⁰▿⁰)◜✧

ubuntu9

5. But I can't apt-get

Remember that we didn't configure network connection right? We will do that now

First, shut down the virtual machine and go to Hyper-V Manager and in Action menu select Virtual Switch Manager...

Create a new Internal virtual switch. This allows us to connect to the virtual machine from hosting machine, using stuff like ssh

switch1

switch2

But, but, I want connect to the Internet!

To connect our virtual machine to the internet, open Network and Sharing Center in Control Panel

Select an active internet connection and click Properties:

In the Sharing tab, Allow other network users to connect through this computer's network connection and select vEthernet (Internal) in Home networking connection

switch3

In Hyper-V Manager, select your virtual machine and in Action menu, select Settings...

In Network Adaptor, select the internal network switch you created earlier.

switch4

This should get you online. Enjoy!

6. Further Notes

If you are on a company intranet, you may need to configure proxy.

  • Go to Settings -> Network -> Network Proxy
  • For system wide proxy on Ubuntu 18 (Original Post Here)
    • Edit /etc/environment to include:
      http_proxy=http://username:password@host:port/
      ftp_proxy=ftp://username:password@host:port/
      https_proxy=https://username:password@host:port/ 
      
    • Edit /etc/apt/apt.conf.d/80proxy to include:
      Acquire::http::proxy "http://username:password@host:port/";
      Acquire::ftp::proxy "ftp://username:password@host:port/";
      Acquire::https::proxy "https://username:password@host:port/";
      

Intro to UNIX Terminal

You can find an intro to UNIX terminal here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment