Running Ubuntu Server 16.04.1 LTS as Hyper-V guest

Posted: February 1, 2017 in Windows Server

In this article we’ll install Ubuntu Server 16.04.01 as Hyper-V VM with 2 CPU’s,1 GB of RAM and 20 GB HDD (Note machine is Generation 1,with Gen 2 it didn’t work for me)

new-vm -Name 'ubuntu' -MemoryStartupBytes 512MB -NewVHDPath 'c:\ubuntu\ubuntu.vhd' -SwitchName 'new virtual switch' -NewVHDSizeBytes 20GB -Generation 1 -MaximumBytes 2GB
set-vm -VMName 'ubuntu' -ProcessorCount 2
Get-VM -Name 'ubuntu' | Add-VMDvdDrive
Set-VMDvdDrive -VMName 'ubuntu' -Path 'C:\Users\dragan\Downloads\ubuntu-16.04.1-server-amd64.iso'

 

1.PNG

 

 

Enabling SSH access on Ubuntu

I don’t know for you,but it’s very uncomfortable to work from Hyper-V console,that’s why i prefer SSH access

apt-get install openssh-server -y
service sshd restart

Allow ssh traffic to your Ubuntu server (192.168.0.48)

ufw allow proto tcp from 192.168.0.0 to 192.168.0.48 port 22

Download and install Putty.You should be able now to make connection to Ubuntu Server via port 22

 

1

Installing integration services

Hyper-V Integration Services allow a virtual machine to communicate with the Hyper-V host .(Think of it as equivalent of VMWare tools).These services enables,for example,guest file copy, while others are important to the virtual machine’s ability to function correctly, such as time synchronization.

apt-get install --install-recommends linux-tools-virtual-lts-xenial linux-cloud-tools-virtual-lts-xenial linux-virtual-lts-xenial

Reboot the Ubuntu Server

If we want to copy files to VM we need to enable Guest Service interface (disabled by default)

On Hyper-V host check current status:

Get-VMIntegrationService -VMName 'ubuntu'

 

capture

Enable-VMIntegrationService -VMname 'ubuntu' -Name 'guest service interface'

Copying file from Hyper-V host to Ubuntu VM:

echo 'This file is about to be copied to ubuntu server'>c:\file.txt
Copy-VMFile -name 'ubuntu' -SourcePath 'C:\file.txt' -DestinationPath '/root/' -FileSource Host

 

1.PNG

Advertisements
Comments
  1. M CLIST says:

    Great walk-through.

    Note: Generation 2 should work (it does for us), provided you disable ‘secure boot’ in the VM settings, before starting up the installation iso. Just add this line to your commands above.

    Set-VMFirmware -VMName ‘VMname’ -EnableSecureBoot Off

    Refer https://technet.microsoft.com/en-us/windows-server-docs/compute/hyper-v/supported-ubuntu-virtual-machines-on-hyper-v

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s