Categories
Setup Technology

Setting up Ubuntu under Hyper-V on Windows 11

First time I post in a long time and I am going right to the nerdy stuff.

OK, so I am trying to play around again with different technologies. Some of the items are easy enough to install on my Windows machine, but that just gets too cluttered at times. Plus, with Visual Studio Code, I can do a lot of the development directly on Linux, which has been a while since I have done anything with it.

So, I think it’s time to get Ubuntu up and running again.

I have used Virtual Box in the past, but found it sometimes problematic in getting the networking operating consistently, and it just seemed too cumbersome. With my most recent machine, I had a copy of Windows 11 Pro, so I can start to work with Hyper-V, so it gave me a new option. (Hyper-V is not available on Win 10/11 Home, unfortunately.)

So, here goes as to what I did to get things up and running.  (Note that these instructions are written for others, but also for me should I need to setup another instance later and so I don’t run through all the same problems again.)

  1. First, ensure that Hyper-V is enabled in Windows.
    1. Open up Search in Windows and look for “Windows Features”. Select the option for “Turn Windows features on or off”.
    2. Scroll down until you see Hyper-V. If it’s unchecked, turn it on and hit “OK”.
    3. You will probably need to reboot your machine to fully enable Hyper-V.
  2. Download the ISO image for Ubuntu that you want.
    1. There are server and desktop images, I used the most recent desktop image.
  3. In Windows, open the Hyper-V Manager app.
  4. In the Action panel, click on New > Virtual Machine. This will start a setup wizard.
    1. Choose a name and location for your VM. Make sure you have the space on your machine wherever you are putting your machine, especially if you plan on providing dynamic HD space.
    2. Specify the Generation. I chose Generation 2 as it has some of the more up to date features that I may need later.
    3. Assign the memory. It’s in bytes, so calculate it accordingly (1 GB = 1,024 MB). Running Ubuntu you don’t need a ton of memory, depending on what you are doing, but if you plan on running an IDE of some kind you’ll want to at least provide some decent amount of RAM. My default is 6 GB/6,144 MB when I set up VMs. This will allow me to scale the memory up or down depending on my needs in the VM setup later.
    4. If you want the VM to have no internet access, choose the default for the Networking Configuration under Connection. If you need network access (for things, like, I don’t know… downloading updates or development packages…) choose “Default Switch”.
    5. Virtual Hard Disk settings I generally leave with the defaults, apart from ensuring I have the right HD location to put the VM set.
    6. For installation options, I choose to install from a bootable image file, and then navigate to the ISO image I downloaded above.
    7. I complete the setup and install the VM.
  5. After the shell of the VM is created, the VM should appear in the Virtual Machines section of the Hyper-V Manager. There is one important setting that should be done at this point and one option setting. Important one first.
    1. Select the VM and then choose Settings (either right click it and choose Settings or from within the Actions pane).
    2. Select the “Security” menu item.
    3. I had lots of problems in There are 2 choices here to make this work to install Ubuntu.
      1. Unlick the “Enable Secure Boot” checkbox. Or,
      2. Keep “Enable Secure Boot” selected and choose “Microsoft UEFI Certificate Authority” from the dropdown.
    4. Note that the above settings allow the ISO image to properly be used for setup. If it’s not set to either of these settings then the ISO for Ubuntu will not run for install as it’s considered “unauthorized code”.
    5. Now choose the “Firmware” menu item. Ensure the DVD drive lists your ISO image. I always move it to the top of the boot order so it doesn’t waste time trying to load from the other types listed. (Worth noting that, after install, the ISO image is removed form the DVD drive setting so you don’t need to demote the DVD drive in the system after it’s all set up.)
    6. Click “Apply” and then “OK”.
  6. Now, select the VM and click “Connect” (either in the Actions pane or by right clicking the VM). The window should open up, so you should then select “Start”.
  7. The Ubuntu installation wizard should now start. Choose whichever settings make the most sense for you. For the most part, I leave the defaults for any configurations as I go through the setup. Let the process run and complete.
    1. It’s worth noting that the lower the RAM amount configured the slower the install goes. I have also had it crap out on me mid-install because there wasn’t enough memory assigned. This is why I default to 6 GB of RAM and then lower it after installation is complete.
    2. Setup your user account. Make sure you remember your login.
  8. After you complete the setup, you’ll get another wizard to configure your profile. Again, the settings here are personal preference, but I generally choose not to send telemetry and also turn off location services.
  9. By default, Ubuntu in the VM runs only in 1024×768 resolution. Even if you fullscreen the VM window, it only takes up a small portion in the middle of your window.
    1. Open the terminal and open the grub settings for editing.

      sudo nano /etc/default/grub

    2. Update the GRUB_CMDLINE_LINUX_DEFAULT variable:

      GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1920x1080"

    3. Exit nano with Ctrl-X and say Yes to save the changes.
    4. Update the grub settings.
    5. Restart Ubuntu.
  10. After all that is done and Ubuntu restarts, I do a final check to ensure that I have the most updated version of everything setup that came with Ubuntu.

    sudo apt-get update && sudo apt-get upgrade

Once all of this is done and Ubuntu reboots, then everything is now set to run it effectively within Hyper-V. Now I can install the software packages I need (after I clone this base VM to use as a fresh starting point to save time for specific other things I want later without having to start with a fresh install).

Leave a Reply

Your email address will not be published. Required fields are marked *