Create a Debian Linux Virtual Machine using Hyper-V
How to create a generation 2 Linux virtual machine on Hyper-V, assign memory, connect virtual switch and virtual hard disk. Then edit the VM settings, attach the ISO image file and install Debian.
The steps in this guide will create a Debian Linux Hyper-V Virtual Machine with 2GB memory, 2 Virtual processors and a 50GB hard disk. These resources should be a good starting point for a Linux VM without a GUI.
Windows Server 2019 Hyper-V, Debian 11
Download the latest DVD amd64 (64-bit) ISO image for Debian
Debian on CDs/DVDs
Create Virtual Machine
Action - New - Virtual Machine
Before you begin - Next
Specify Name and Location - enter VM name
Store the virtual machine in a different location
In this example, the Hyper-V server has two drives; C drive for the Windows OS and D drive for VM Data.
We've already configured the Virtual Hard Disk and Virtual Machine folders in the Hyper-V Settings so we don't need to change this setting.
Specify Generation - Generation 2
- Generation 2 virtual machines have more features than generation 1
- You should only create a generation 1 VM if the guest operating system you want to install isn't supported on generation 2
Should I create a generation 1 or 2 virtual machine in Hyper-V?
Debian guest operating system support
Hyper-V feature compatibility by generation and guestby Author
Enter startup memory e.g. 2048MB / 2GB
Tick use dynamic Memory for this virtual machine
Dynamic memory allows Hyper-V to add more memory to a guest OS when it's needed or remove it when the VM memory usage drops. This allows VMs to share the host's available physical memory more efficiently as the guests only use memory when they need it.
Configure Networking - Connect virtual switch
Connect Virtual Hard Disk
Set virtual disk size e.g. 50GB
- Creating a virtual hard disk (VHD) using the New virtual machine wizard will automatically create a dynamically expanding VHD.
- A Dynamically expanding VHD will automatically expand to the available maximum size.
- Dynamically expanding VHDs are thin-provisioned, they are initially small and increase in size as data is added.
Installation Options - Install an operating system later
We will attach the Debian ISO file to the VM in the next steps.
Edit Virtual machine settings
Dynamic Memory - set Maximum RAM to 2048MB / 2GB
Number of virtual processors 2
DVD Drive - add
Image file - browse to select ISO image file
Change boot order so DVD drive is first
Untick enable secure boot
Automatic Start and Stop Actions
Automatic Start Actions
Always start this virtual machine automatically
Automatic Stop Actions
Shut down the guest operating system
Nice job with the article. What about having Debian (in HypeV) reach/mount back to the host's resources? Ex. in the VM mount a shared drive.
Thanks for the feedback on the guide. You can copy text from the VM using a terminal app like Putty or transfer files to/from the VM using SSH; I use FileZilla for this. Another option is to shutdown the VM and mount the virtual hard disk .vhdx file on the Hyper-V host. Then you can access all of the files on the VM disk.
Important note: The default virtual switch for Hyper-V allows the VM to piggyback off of the host's IP configuration. The VM will have internet access but will not be accessible from any computer other than the host.
You can create a new switch using the Virtual Switch Manager (in the actions panel on the right of the main Hyper-V Manager screen)... External switch, link it to your Ethernet card... and it will appear on your network as an independent device with its own IP, allowing you to forward ports to it.
Thanks for the feedback. Hyper-V virtual switch configuration isn't covered in the guide so this could be useful info for others
Just installed Debian 11 with same parameters.
Partitionning is encrypted LVM.
Issue: at boot up, impossible to enter the password to decrypt the volume. Apparently some other users have the same issue but I have seen no solution to fix this so far...a