Skip to content

Instantly share code, notes, and snippets.

@lunitrixx
Forked from deoren/Ubuntu_on_Hyper-V.md
Created January 26, 2023 05:43
Show Gist options
  • Save lunitrixx/61028d40601c3e0517ff366b2a942d2c to your computer and use it in GitHub Desktop.
Save lunitrixx/61028d40601c3e0517ff366b2a942d2c to your computer and use it in GitHub Desktop.

Revisions

  1. @deoren deoren revised this gist Jun 30, 2018. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions Ubuntu_on_Hyper-V.md
    Original file line number Diff line number Diff line change
    @@ -54,6 +54,10 @@ packages for the active version of the kernel like so:
    1. `export running_kernel=$(uname -r); sudo apt-get install linux-tools-${running_kernel} linux-cloud-tools-${running_kernel}`
    1. `sudo reboot`

    An alternative for step 2 is to run:

    1. `sudo apt-get install -s linux-cloud-tools-generic-hwe-16.04 linux-tools-generic-hwe-16.04`

    Result:

    `ubuntu@ubuntu-1604-test:~$ dpkg -l | grep linux | grep -E "image|tools" | awk '{print $2, $3}' | sort`
  2. @deoren deoren revised this gist Jun 30, 2018. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions Ubuntu_on_Hyper-V.md
    Original file line number Diff line number Diff line change
    @@ -11,8 +11,6 @@ Short version: See docs.microsoft.com link below.

    ### Ubuntu 16.04

    #### Best case

    1. `sudo apt-get update`
    1. `sudo apt-get install linux-virtual-lts-xenial linux-tools-virtual-lts-xenial linux-cloud-tools-virtual-lts-xenial`

  3. @deoren deoren revised this gist Jun 30, 2018. 1 changed file with 75 additions and 0 deletions.
    75 changes: 75 additions & 0 deletions Ubuntu_on_Hyper-V.md
    Original file line number Diff line number Diff line change
    @@ -11,9 +11,84 @@ Short version: See docs.microsoft.com link below.

    ### Ubuntu 16.04

    #### Best case

    1. `sudo apt-get update`
    1. `sudo apt-get install linux-virtual-lts-xenial linux-tools-virtual-lts-xenial linux-cloud-tools-virtual-lts-xenial`

    #### Common problems


    ##### Failure to copy files to the guest via `Copy-VMFile`

    To confirm run `systemctl status hv-fcopy-daemon.service` and you will see output
    similar to this:

    ```
    ● hv-fcopy-daemon.service - Hyper-V File Copy Protocol Daemon
    Loaded: loaded (/lib/systemd/system/hv-fcopy-daemon.service; enabled; vendor preset: enabled)
    Active: failed (Result: exit-code) since Sat 2018-06-30 13:37:34 CDT; 11min ago
    Process: 718 ExecStart=/usr/sbin/hv_fcopy_daemon -n (code=exited, status=2)
    Main PID: 718 (code=exited, status=2)
    Jun 30 13:37:34 ubuntu-1604-test hv_fcopy_daemon[718]: WARNING: hv_fcopy_daemon not found for kernel 4.13.0-45
    Jun 30 13:37:34 ubuntu-1604-test hv_fcopy_daemon[718]: You may need to install the following packages for this specific kernel:
    Jun 30 13:37:34 ubuntu-1604-test hv_fcopy_daemon[718]: linux-tools-4.13.0-45-generic
    Jun 30 13:37:34 ubuntu-1604-test hv_fcopy_daemon[718]: linux-cloud-tools-4.13.0-45-generic
    Jun 30 13:37:34 ubuntu-1604-test hv_fcopy_daemon[718]: You may also want to install one of the following packages to keep up to date:
    Jun 30 13:37:34 ubuntu-1604-test hv_fcopy_daemon[718]: linux-tools-generic
    Jun 30 13:37:34 ubuntu-1604-test hv_fcopy_daemon[718]: linux-cloud-tools-generic
    Jun 30 13:37:34 ubuntu-1604-test systemd[1]: hv-fcopy-daemon.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
    Jun 30 13:37:34 ubuntu-1604-test systemd[1]: hv-fcopy-daemon.service: Unit entered failed state.
    Jun 30 13:37:34 ubuntu-1604-test systemd[1]: hv-fcopy-daemon.service: Failed with result 'exit-code'.
    ```

    Explanation:

    When installing later releases of Ubuntu 16.04 (e.g., .3, .4, etc) a newer kernel
    is included. This kernel is set as the active kernel and will not work with the
    "tools" packages installed by following the earlier instructions.

    To fix this, you have to either downgrade to the LTS kernel *or* install the "tools"
    packages for the active version of the kernel like so:

    1. `sudo apt-get update`
    1. `export running_kernel=$(uname -r); sudo apt-get install linux-tools-${running_kernel} linux-cloud-tools-${running_kernel}`
    1. `sudo reboot`

    Result:

    `ubuntu@ubuntu-1604-test:~$ dpkg -l | grep linux | grep -E "image|tools" | awk '{print $2, $3}' | sort`

    ```
    linux-base 4.5ubuntu1~16.04.1
    linux-cloud-tools-4.13.0-45-generic 4.13.0-45.50~16.04.1
    linux-cloud-tools-4.4.0-128 4.4.0-128.154
    linux-cloud-tools-4.4.0-128-generic 4.4.0-128.154
    linux-cloud-tools-common 4.4.0-128.154
    linux-cloud-tools-generic 4.4.0.128.134
    linux-cloud-tools-virtual 4.4.0.128.134
    linux-cloud-tools-virtual-lts-xenial 4.4.0.128.134
    linux-hwe-cloud-tools-4.13.0-45 4.13.0-45.50~16.04.1
    linux-hwe-tools-4.13.0-45 4.13.0-45.50~16.04.1
    linux-image-4.10.0-28-generic 4.10.0-28.32~16.04.2
    linux-image-4.13.0-45-generic 4.13.0-45.50~16.04.1
    linux-image-4.4.0-128-generic 4.4.0-128.154
    linux-image-extra-4.10.0-28-generic 4.10.0-28.32~16.04.2
    linux-image-extra-4.13.0-45-generic 4.13.0-45.50~16.04.1
    linux-image-generic-hwe-16.04 4.13.0.45.64
    linux-image-virtual 4.4.0.128.134
    linux-signed-image-4.13.0-45-generic 4.13.0-45.50~16.04.1
    linux-signed-image-generic-hwe-16.04 4.13.0.45.64
    linux-tools-4.13.0-45-generic 4.13.0-45.50~16.04.1
    linux-tools-4.4.0-128 4.4.0-128.154
    linux-tools-4.4.0-128-generic 4.4.0-128.154
    linux-tools-common 4.4.0-128.154
    linux-tools-generic 4.4.0.128.134
    linux-tools-virtual 4.4.0.128.134
    linux-tools-virtual-lts-xenial 4.4.0.128.134
    ```

    ## Set video resolution

    By default the screen size is small ...
  4. @deoren deoren revised this gist Jun 27, 2018. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions Ubuntu_on_Hyper-V.md
    Original file line number Diff line number Diff line change
    @@ -27,6 +27,16 @@ By default the screen size is small ...

    The resolution should now be set as specified.

    ## Enable NOOP scheduler for better I/O performance

    1. Open Terminal
    1. Type: `sudo nano /etc/default/grub`
    1. Find the line starting with `GRUB_CMDLINE_LINUX_DEFAULT`, and add `elevator=noop`.
    My line ends up looking like this: `GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1280x720 elevator=noop"`
    1. Write the changes and quit nano.
    1. Run: `sudo update-grub`
    1. Reboot the virtual machine

    ## References

    - https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/supported-ubuntu-virtual-machines-on-hyper-v
  5. @deoren deoren revised this gist Jan 27, 2018. 1 changed file with 26 additions and 1 deletion.
    27 changes: 26 additions & 1 deletion Ubuntu_on_Hyper-V.md
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,31 @@ Short version: See docs.microsoft.com link below.

    By default the screen size is small ...

    1. Open Terminal
    1. Type: `sudo nano /etc/default/grub`
    1. Find the line starting with `GRUB_CMDLINE_LINUX_DEFAULT`, and add `video=hyperv_fb:DESIRED_RESOLUTION`. The resolution I want is `1280x720`. So my line ends up looking like this: `GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1280x720"`
    1. Write the changes and quit nano.
    1. Run: `sudo update-grub`
    1. Reboot the virtual machine

    The resolution should now be set as specified.

    ## References

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

    - https://blogs.msdn.microsoft.com/virtual_pc_guy/2014/09/19/changing-ubuntu-screen-resolution-in-a-hyper-v-vm/

    - https://www.quora.com/How-can-I-adjust-the-screen-resolution-for-an-Ubuntu-virtual-machine-on-a-Windows-10-host-1

    - http://askubuntu.com/questions/384602/ubuntu-hyper-v-guest-display-resolution

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

    - http://www.serverwatch.com/server-tutorials/installing-and-activating-hyper-v-linux-integration-services.html

    - http://www.altaro.com/hyper-v/ubuntu-linux-server-hyper-v-guest/

    - https://technet.microsoft.com/en-us/windows-server-docs/compute/hyper-v/best-practices-for-running-linux-on-hyper-v

    - https://blogs.technet.microsoft.com/keithmayer/2013/11/21/at-your-service-out-of-band-vm-updates-with-guest-services-in-windows-server-2012-r2-hyper-v/
  6. @deoren deoren created this gist Jan 27, 2018.
    23 changes: 23 additions & 0 deletions Ubuntu_on_Hyper-V.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    # Enabling full Hyper-V support for Ubuntu

    ## Install packages

    Short version: See docs.microsoft.com link below.

    ### Ubuntu 17.04 and later

    1. `sudo apt-get update`
    1. `sudo apt-get install linux-image-virtual linux-tools-virtual linux-cloud-tools-virtual`

    ### Ubuntu 16.04

    1. `sudo apt-get update`
    1. `sudo apt-get install linux-virtual-lts-xenial linux-tools-virtual-lts-xenial linux-cloud-tools-virtual-lts-xenial`

    ## Set video resolution

    By default the screen size is small ...

    ## References

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