> For the complete documentation index, see [llms.txt](https://ploegert.gitbook.io/til/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ploegert.gitbook.io/til/general/virtualization/ubuntu/hyper-v-setup-an-ubuntu-20.04-vm.md).

# Hyper-V - Setup an Ubuntu 20.04 vm

Open up Hyper-V Manager, and create "**New" vm**

![](/files/b8ERVkJrurTSlgvuBLoD)

Select **Next:**

![](/files/LMuq7EsvX0k4uXY6B6DH)

**Type in a Name and then select Next**

![](/files/hTGWhJYCQZ5HeUK523ID)

Then Select **"Generation 2"**

![](/files/JsuqVUzbBIUEUgYf8fFc)

Put in the amount of memory you'd like to use. I use **2048**

![](/files/yRbxGszJa2zcFFEBJDvG)

Configure your networking by selecting **"Default"**

![](/files/MpLGn5XYMf4p9kuOB9DP)

Nothing to change here, select **"Next"**

![](/files/LNY0SyTeEZ633GB51n4q)

Here you will want to select the iso image you'll be using. loaded my iso file from 20.04 LTS from this url: <https://ubuntu.com/download/desktop>

![](/files/iReKycTW2EjIWk0sbR9V)

Select the image file

![](/files/XhHm3VEhROqaBFVdDJ4s)

Then select **finish** from here

![](/files/e2nfEfSMlv2rjuoRMvgc)

### Configure VM Settings

Now we have created the vm, we'll want to tweak some settings.

Right click on your vm and select "**settings**"

![](/files/HjFI2Nh7XO05fgZJcdlP)

Then go and select "**Security**" tab

![](/files/qkbQOQg042dUl9bHaVUM)

And then select **"Microsoft UEFI Certificate Authority**",&#x20;

![](/files/SE6MRcjjNOF8nKsfosBb)

Then select **"Integration Services"**, and check **"Guest Services"**

![](/files/bf4GLDvWPbN4LaVGtTLT)

Then click "**Checkpoints"** section and disable **"Enable Checkpoints"**

![](/files/lPimsmGL8a2v5nt1up5y)

Then select "**OK"** to close

![](/files/UdEatZS5WnbvLsRZV3es)

You should now be able to run your image.

### Launching the VM

Right click on your vm in Hyperv-Manager, and then select "Run"

![](/files/XOjreRtZrw5LFbTALD2R)

Then select "**Install**" in the ubuntu dialog that pops up:

![](/files/Iosukv3N4VL1Gyn4FAbf)

On Keyboard Layouts, just select the default and select "**continue"**:

![](/files/SbQlL6e2hDM0l4UdD8EV)

Select Updates by selecting "**Install third-party software for graphics and wifi hardware and additional media formats**", then select "**Configure Secure Boot**" and enter your secure password.

![](/files/EM9GOTa23sD5cUEFzxAK)

On Installation type, lets select "**Advanced Features"**

![](/files/jE68UEfyPJYY0yBYKlVN)

Check the **"Use LVM with the new Ubuntu installation",** and select **"Encrypt the new Ubuntu installation for security"** and then select **"OK"**

![](/files/bSiQUF8Lg6msTIZWEaGO)

Then select **"Install Now"**

![](/files/1CnJ8gqou3WkriGYXI97)

Now you'll enter a security key, and select recovery key as shown below

![](/files/lcngsxAFHeB0FLgWxW2b)

Now you'll elect to write the changes to disk by selecting continue:

![](/files/a9yvg73AwJ94siNYpkyY)

Now, you'll select your time zone:

![](/files/Q5oE6r7T6nRQOxFF5pMF)

Now you'll enter the information about the desktop, such as your name, password, and machine name:

![](/files/f95SKN0duHVhdZLhNHW0)

You should now see it installing & configuring...

![](/files/ry2ntkpLvTdSTMazeqJk)

YOu'll now be prompted to restart your machine:

![](/files/snKT3bw4UnTWL1hqnZIk)

### Running Commands to get the basics setup

The following should get you up and running so you can rpd into your local hyperv vm

```bash
sudo apt update

# Useful Pre-Reqs
sudo apt-get install unzip

# Install virtual Drivers
sudo apt install -y linux-tools-virtual
sudo apt install -y linux-cloud-tools-virtual

# Run Config Script to download & configure RDP parts
cd Downloads/
wget https://raw.githubusercontent.com/Hinara/linux-vm-tools/ubuntu20-04/ubuntu/20.04/install.sh
sudo chmod +x install.sh
sudo ./install.sh
init 6
cd Downloads/
sudo ./install.sh 
sudo apt update

#Reboot again just to be sure
init 6
```

### Virtual Box Additions

If you're using Virtual Box, you may want to add the Guest Additions. Youn the following command first, before mounting.

Reference here: <https://itsfoss.com/virtualbox-guest-additions-ubuntu/>

```
sudo apt install build-essential dkms linux-headers-generic 
```

### Additional Tools

Add some Additional Tools

```
#======================================
# Install Edge
cd Downloads/
sudo apt install ./microsoft-edge-beta_97.0.1072.21-1_amd64.deb 
sudo apt-get install libatomic1

#======================================
# Setup VSCode Repos
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg

# Install VSCode
sudo apt install apt-transport-https
sudo apt update
sudo apt install code # or code-insiders
```
