Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Install Linux in a virtual machine

By updated

Improve this page

To learn Linux administration, you need a system to practise on. A simple option is to install Linux in a virtual machine (VM) on your current computer. You get a complete server, isolated from your main system, that you can break and rebuild at will. If the notion of a VM is new to you, What is a virtual machine? (in French) explains it in detail.

What you will learn

  • Install a virtualization tool on your computer
  • Download the official ISO image of a server distribution
  • Create a virtual machine with suitable resources
  • Install Linux in server mode (without a graphical interface)
  • Log in to the VM after the first boot

Prerequisites

  • A computer with at least 4 GB of RAM and 20 GB of free disk space
  • No virtualization tool is assumed: the "Install a virtualization tool" section walks you through it
  • Having read the guide Choose a server distribution

Choose a virtualization tool

SoftwareHost systemLevelNote
Hyper-VWindows Pro, Enterprise (not Home)IntermediateBuilt into Windows, enabled as a feature
VMware WorkstationWindows, LinuxBeginnerFree since November 11, 2024, businesses included, with no support from Broadcom
virt-manager (KVM)Linux onlyIntermediateUses the hypervisor of the Linux kernel, common tool on Linux
UTMmacOS (Apple Silicon and Intel)BeginnerFree and open source, based on QEMU; needs an arm64 ISO on an Apple chip

This lesson does not recommend VirtualBox: with dsoxlab, the tool that runs the labs of this course, the labs with virtual machines freeze on it. The choice depends on your system. On Windows Pro or Enterprise, Hyper-V is already part of the system; on Windows Home, pick VMware Workstation. On Linux, pick virt-manager and KVM: the hypervisor (the software that runs the VMs) is already part of the kernel. On a Mac, pick UTM. On an Apple chip (M1 and later), download the arm64 ISO of the distribution: an amd64 ISO does not run at full speed there (Debian: netinst images, arm64 included; Ubuntu: Ubuntu Server for ARM). The ISO names given below are amd64 examples.

What about the dsoxlab labs?

This lesson is about learning Linux in a VM, not about running dsoxlab. On the tool side, the dsoxlab appliance (a ready-to-use VM, shipped as .ova or .qcow2) was tested with QEMU/KVM, where everything works. Do not use VirtualBox for dsoxlab: the labs with virtual machines get stuck on it. VMware Workstation and Fusion were not tested, and no image exists for Hyper-V. On Windows 11, another route exists: WSL2 runs Ubuntu with a real Linux kernel, and dsoxlab creates the machines of the labs as it does on an ordinary Linux, provided ls -l /dev/kvm finds the file in Ubuntu. It is missing on Windows 10, with nestedVirtualization=false in .wslconfig, or when Windows itself runs inside a VM (steps in Install dsoxlab locally). On an Intel Mac, no combination is validated today for these labs; the dsoxlab appliance remains the documented route.

Another option is to install dsoxlab inside the Debian or Ubuntu VM created here: the page Install dsoxlab locally installs it on Linux, including inside a VM, and terminal labs need no hypervisor. Labs with virtual machines need /dev/kvm, so either KVM on Linux or nested virtualization inside the VM. This option was not tested for this lesson.

Install a virtualization tool

A virtualization tool (a desktop hypervisor) creates and runs virtual machines. It needs the processor to offer hardware virtualization (Intel VT-x or AMD-V), which is sometimes disabled by default in the BIOS or UEFI of the computer. If the installation or the first boot of a VM fails, check this setting first. Pick the tab for your system; each tab ends with a way to check that the tool works.

Hyper-V ships with Windows 10 and 11 in the Pro or Enterprise editions, so there is nothing to download. The Home edition cannot install it: switch to the VMware Workstation tab instead. Microsoft also requires a 64-bit processor with SLAT (second-level address translation) and at least 4 GB of memory.

Open PowerShell as administrator, then enable the feature and accept the restart:

Terminal window
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

After the restart, check the state of the feature, then search for "Hyper-V Manager" in the Start menu. It must open:

Terminal window
Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V

The State line must read Enabled. Source: Enable Hyper-V (Microsoft Learn, read on November 16, 2026).

Once the tool is checked, the rest of the page applies to all four: download an ISO, create the VM, install.

Download the ISO image

Go to the official website of the distribution you chose and download the netinstall or server image (not the desktop edition):

Official site: debian.org/download

Download the netinst image (about 750 MB). It contains the minimum needed to start the installation and downloads the rest from the Internet.

debian-13.x.x-amd64-netinst.iso

The current stable release is Debian 13 "Trixie". To install it step by step, follow Install Debian 13 on a server, which walks through every screen of the installer with screenshots. Before putting it into production, read what changes on a server with Debian 13 (in French): /tmp mounted in RAM, sysctl.conf ignored by default, the last command removed, and the procedure to upgrade from Debian 12.

Check the integrity of the ISO

This image is about to install an entire system: check it before you use it. A checksum (also called a digest) is the result of a calculation on the content of a file: if a single byte changes, the checksum changes. Distributions store their checksums in a text file, placed in the same directory as the ISO on their download server. Debian publishes two, SHA256SUMS and SHA512SUMS, in the directory of the netinst image (https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/); Ubuntu publishes SHA256SUMS in the directory of its release (https://releases.ubuntu.com/26.04/). Download this file into the folder that holds the ISO, then run the comparison from that folder:

Terminal window
sha256sum --ignore-missing -c SHA256SUMS

The file lists every image of the release, and you downloaded only one: --ignore-missing skips the others. The command recomputes the checksum of your ISO, compares it with the line that carries its name and prints the verdict:

debian-13.8.0-amd64-netinst.iso: OK

FAILED instead of OK signals a mismatch, caused by an incomplete download or an image tampered with on the way. In both cases, download the image again rather than attempting the installation. With SHA512SUMS, the command becomes sha512sum --ignore-missing -c SHA512SUMS: a SHA512 checksum is never compared with sha256sum. The lesson Check the integrity of a file covers these commands in detail.

A checksum published in the same place as the ISO does not protect you from a compromised site. Distributions therefore sign the checksum file. At Debian, each checksum file has its signature (SHA256SUMS.sign, SHA512SUMS.sign); at Ubuntu, SHA256SUMS comes with SHA256SUMS.gpg. With GnuPG, the verification command for Ubuntu is the one below, and it must print Good signature from "Ubuntu CD Image Automatic Signing Key, followed by the name of the key:

Terminal window
gpg --keyid-format long --verify SHA256SUMS.gpg SHA256SUMS

If GnuPG answers No public key, you first need to import the distribution key. The procedures are in Verifying authenticity of Debian images and How to verify your Ubuntu download (read on November 16, 2026). GnuPG also prints a "This key is not certified with a trusted signature" warning: it only means that you have not yet established trust in the key.

Create the virtual machine

A learning VM does not need much: without a graphical interface, a Linux server fits in 2 GB of memory. The values in the table below are the recommended starting point. With dynamic allocation, a disk declared at 20 GB only takes the space actually written on your computer at first, and grows with use.

ResourceRecommended value
RAM2 GB
CPU2 vCPU
Disk20 GB (dynamic)
NetworkNAT (Internet access from the VM); Hyper-V offers a virtual switch instead
  1. Open Hyper-V Manager, then Action → New → Virtual Machine

  2. Give the VM a name (for example debian-lab) and choose generation 2 (UEFI)

  3. Assign 2048 MB of memory

  4. At the Configure Networking step, choose the virtual switch offered. Without a switch, the VM has no network

  5. Create a virtual hard disk of 20 GB

  6. Choose Install an operating system from a bootable image file and select the ISO

  7. Before starting, open the VM Settings: the Security section sets Secure Boot (see the troubleshooting section) and the Processor section lets you switch to 2 virtual processors

Install Linux step by step

The installer asks a series of questions. These are the recommended choices for a learning server:

  1. Language and keyboard: choose English or your native language, as you prefer. In production, servers usually run in English, but for learning your own language can be more comfortable.

  2. Hostname: give a short, descriptive name, for example lab-debian or srv-linux. This name will appear in your prompt.

  3. User account: create a standard user with a password. On Debian, the installer first asks for a root password: leave it empty. The root account then stays locked and the account you create next receives the sudo right. With a locked root account, su - refuses to open a session for you: to become root, use sudo -i. The rescue and emergency boot modes refuse the shell as well, as the Linux reboot and shutdown lesson explains.

    If you set a root password anyway, your account is not in the sudo group and the sudo apt update of step 3 in "First boot and login" fails. To recover without reinstalling, open a root session with su - (root password), install sudo with apt install sudo if it is missing, then add your account to the group with usermod -aG sudo <account>. Log out and log back in: the group is only taken into account at the next session.

    On Ubuntu Server, the root account is disabled by default: you use sudo.

  4. Partitioning: choose Use an entire disk (guided partitioning). It is the simplest choice, and it is enough to learn. Advanced partitioning (LVM, separate partitions) is covered in dedicated guides.

  5. Software selection: on Debian, untick everything except "SSH server" and "standard system utilities". On Ubuntu Server, tick the OpenSSH server installation and none of the packages offered afterwards. On AlmaLinux or Rocky, choose the minimal installation. No graphical interface, no web server: you will then install what you need, one command at a time.

  6. GRUB: if the installer asks (Debian does), accept installing the GRUB boot loader on the main disk. Without it, the VM will not boot.

  7. Finish: the installer asks you to remove the installation media. Hyper-V, VMware Workstation and virt-manager usually do it automatically; with UTM, you must remove the ISO by hand after the installation: in the detail view of the VM, open the drive menu and eject the image (UTM documentation, read on November 16, 2026). Without that, the installer may start again at the reboot (see the troubleshooting section). Reboot.

First boot and login

After the reboot, the VM shows a text login screen:

lab-debian login: _
  1. Log in with the username and password created during the installation

  2. Check that the network works:

    Terminal window
    ip addr show
    ping -c 3 1.1.1.1
  3. Update the system (the guide update your Linux system details these commands):

    Terminal window
    sudo apt update && sudo apt upgrade -y
  4. Check the installed version:

    Terminal window
    cat /etc/os-release
    uname -r

    The first lines of /etc/os-release give the name and version of the distribution; uname -r gives the kernel version. Here is what systems that were up to date that day displayed on November 13, 2026 (the kernel version changes with updates):

    Debian 13, start of /etc/os-release then uname -r
    PRETTY_NAME="Debian GNU/Linux 13 (trixie)"
    NAME="Debian GNU/Linux"
    VERSION_ID="13"
    VERSION="13 (trixie)"
    VERSION_CODENAME=trixie
    6.12.116+deb13-amd64
    Ubuntu Server 26.04.1, start of /etc/os-release then uname -r
    PRETTY_NAME="Ubuntu 26.04.1 LTS"
    NAME="Ubuntu"
    VERSION_ID="26.04"
    VERSION="26.04.1 LTS (Resolute Raccoon)"
    VERSION_CODENAME=resolute
    7.0.0-43-generic
    AlmaLinux 10.2, start of /etc/os-release then uname -r
    NAME="AlmaLinux"
    VERSION="10.2 (Lavender Lion)"
    RELEASE_TYPE=stable
    ID="almalinux"
    ID_LIKE="rhel centos fedora"
    6.12.0-211.74.2.el10_2.x86_64

    On AlmaLinux, PRETTY_NAME is not in the first five lines: the name and version are read from NAME and VERSION.

Working directly in the VM console is uncomfortable (no copy and paste, no resizing). Connect over SSH from your usual terminal instead:

Terminal window
ssh user@vm-ip-address

To find the IP address of the VM:

Terminal window
ip -4 addr show

The path to the VM depends on the network of your virtualization tool:

  • virt-manager: the default libvirt NAT network lets the host reach the VM at its address, in the 192.168.122.0/24 range. A plain ssh user@vm-ip-address is enough.
  • Hyper-V: the VM receives its address from the virtual switch you connected it to. Read the address with ip -4 addr show inside the VM, then run ssh from Windows. If the connection fails, check the switch type in the Virtual Switch Manager: a private switch isolates the VM from the host. Test with ping from the host.
  • VMware Workstation: NAT mode gives the VM an address on a private network managed by VMware, which the host usually reaches directly. Read the address inside the VM and test ssh; if the connection fails, look at the virtual network settings of Workstation.
  • UTM: access from the Mac depends on the network mode chosen in the VM settings. Read the address inside the VM and test ssh; with no answer, try the shared mode or add a port forwarding rule in those settings.

In every case, a ping from the host to the VM address tells you whether the path exists before you blame ssh. A port forwarding rule, when the software offers one, makes the VM reachable through a host port: ssh -p 2222 user@127.0.0.1 for a host port 2222 forwarded to guest port 22.

Troubleshooting

These symptoms fall into two groups. The first four in the table happen before Linux boots. They come from virtualization disabled in the BIOS of the computer, or from the VM settings: a boot order that skips the ISO, a Secure Boot that refuses Linux (Hyper-V), a virtual drive still holding the ISO. The last two affect the network of the installed system and are fixed from inside the VM.

SymptomLikely causeFix
The VM does not boot from the ISOWrong boot orderCheck that the CD/DVD comes first in the boot order
The software reports that hardware virtualization is unavailableVirtualization disabled in the BIOSEnable Intel VT-x or AMD-V in the BIOS/UEFI of the computer
Hyper-V: the generation 2 VM does not boot from the ISOThe Secure Boot of the VM refuses the Linux boot loaderIn the VM settings, Security section, choose the "Microsoft UEFI Certificate Authority" Secure Boot template or disable Secure Boot
The installer starts again after the rebootISO still in the virtual driveRemove the ISO from the virtual drive and reboot
No network after installationInterface not configuredCheck with ip link that the interface is UP, then restart the connection with the tool that manages the network: sudo netplan apply (Ubuntu), sudo nmcli device connect <interface> (AlmaLinux, Rocky, RHEL), sudo ifup <interface> (Debian, if ifup exists)
ping works but apt update failsDNS not configuredRead /etc/resolv.conf and, if systemd-resolved is running, resolvectl status; fix the DNS in the tool that manages the network, not in the file

Network and DNS: what three cloud images show

The same failure is fixed with the tool that manages the network, and the "Fix" column of the table follows that difference: netplan on Ubuntu, NetworkManager on AlmaLinux, for example, each with its own repair command. The outputs below date from November 13, 2026 and come from three VMs built from cloud images, not from an installation from the ISOs of this page. An installation from the ISO may manage the network with another tool: identify the one on your machine before choosing the command.

On the Ubuntu Server 26.04.1 cloud image, netplan is present and systemd-networkd manages the network. With the interface brought down by ip link set enp5s0 down, sudo netplan apply brought it back up, with its IPv4 address:

Ubuntu 26.04.1, ip -br link and ip -br addr after sudo netplan apply
enp5s0 UP 00:16:3e:cd:00:12 <BROADCAST,MULTICAST,UP,LOWER_UP>
enp5s0 UP 10.10.96.13/24 fe80::216:3eff:fecd:12/64

On the AlmaLinux 10.2 cloud image, NetworkManager manages the network. Same scenario: the command answered that the interface was activated, and it went back to UP with its address.

AlmaLinux 10.2, sudo nmcli device connect enp5s0
Device 'enp5s0' successfully activated with '8e20a070-5446-5898-8eb4-71a36c80e35d'.

On the Debian 13 cloud image, the ifupdown package is absent (dpkg -l ifupdown answers un, "unknown"), the /etc/network/interfaces file does not exist and ifup is not an available command. systemd-networkd is active, NetworkManager and the networking service are inactive. On this image, sudo ifup <interface> therefore does not work. On your installation made from the ISO, run dpkg -l ifupdown and ls /etc/network/interfaces: the ifup command only exists if ifupdown is installed, and that file is the one it reads. If both are present, sudo ifup <interface> applies the configuration. If either is missing, another tool manages the network of your installation.

For DNS, on the Debian 13 and Ubuntu 26.04 cloud images, /etc/resolv.conf is a link to /run/systemd/resolve/stub-resolv.conf and starts with "Do not edit". The useful line is nameserver 127.0.0.53, the address of the local resolver of systemd-resolved, and the servers actually used are read with resolvectl status (Current DNS Server: 10.10.96.1 on the Debian image). On the AlmaLinux 10.2 image, it is an ordinary file, produced by NetworkManager:

AlmaLinux 10.2, cat /etc/resolv.conf
# Generated by NetworkManager
search incus lab.lab
nameserver 10.10.96.1

When the file is generated, as in these three cases, a nameserver added by hand does not last: systemd-resolved or NetworkManager regenerates it. The lasting fix goes through the network configuration tool. To know whether this is your case, run ls -l /etc/resolv.conf: a link indicates a file managed by the system. Finally, resolvectl status fails on AlmaLinux (Failed to get global data: The name is not activatable), because systemd-resolved is not running there.

Put it into practice

Once the machine is installed, the lab has you describe what runs on it. It prepares a separate working folder, with a vm-info.txt file to fill in. The lab reads /proc/meminfo and /sys/block, so it needs a Linux: a Linux computer, Ubuntu in WSL2 on Windows 11, or the VM created above if you installed dsoxlab in it. It cannot be played directly on macOS. With the commands below, you read the number of processors, the architecture, the total memory in kilobytes and the name of a disk, then write these four values into the file. For the disk, write the name of a disk (sda, vda, nvme0n1), not that of a partition such as sda1. Validation compares each value with the real state of the machine: an invented value fails.

Terminal window
nproc
uname -m
grep MemTotal /proc/meminfo
lsblk -dno NAME

nproc prints the number of available processors; in a VM, these are the vCPUs you assigned to it. uname -m prints the architecture (x86_64 for an amd64 ISO, aarch64 for an arm64 ISO). The MemTotal line of /proc/meminfo, in kilobytes, gives the memory seen by the system, slightly lower than the amount assigned to a VM. lsblk -dno NAME prints only the names of the disks, without their partitions: in your own VM, the 20 GB disk appears there. lsblk alone adds the sizes and the partitions.

To write these values, you edit vm-info.txt with a text editor for the terminal. nano is fine for a first try: it shows its shortcuts at the bottom of the screen, where ^O means Ctrl + O, that is, the Ctrl key held down with the letter O (not the digit zero). On a Mac, Ctrl is still the key to use, not Cmd. It is installed by default on Debian and Ubuntu, but some images do not have it, and neither does a minimal installation of AlmaLinux 10. If it is missing, install it with sudo apt install nano (Debian, Ubuntu) or sudo dnf install nano (AlmaLinux).

  1. Go to the lab folder: dsoxlab run l1-prepare-vm prepares the lab and opens a subshell in its working directory, challenge/work/, where vm-info.txt already exists. When you are done, exit closes this subshell.

  2. Open the file:

    Terminal window
    nano vm-info.txt
  3. Replace each <value>. The file is prefilled: each field is written NAME: <value>, for example CPU_COUNT: <value>, and lines that start with # are comments to leave alone. Move down with the arrow keys to <value>, delete it with Backspace, then type the value you read. Keep the field name and the colon: CPU_COUNT: followed by the value of nproc.

  4. Save with Ctrl + O. Nano shows the file name and waits for a confirmation: press Enter.

  5. Exit with Ctrl + X. If you saved at the previous step, nano closes right away. If it still asks whether to save, you changed the text since then: answer "yes" with the key shown at the bottom of the screen, then Enter. To exit without saving anything, also type Ctrl + X, then refuse with the "no" key shown at the bottom of the screen.

  6. Read the file again to check that it contains your values:

    Terminal window
    cat vm-info.txt

The guide Nano: edit, save and exit a file covers the other shortcuts (copy, paste, search).

Key points

  • A virtual machine is a good place to learn: isolated and disposable.
  • Always download the ISO from the official site, check its checksum (SHA256 or SHA512) and, if possible, the signature of the checksum file.
  • Install a suitable virtualization tool first: Hyper-V or VMware Workstation on Windows, KVM on Linux, UTM on Mac.
  • Install a minimal system (SSH and standard utilities); you will add the rest as you go.
  • Guided partitioning is enough to learn. Advanced partitioning has its own module, in the Storage part.
  • Connect over SSH rather than through the VM console, for comfort.

Knowledge check

Check that the essentials of this guide stuck. The questions cover only what has just been explained here.

Knowledge check

Check what you have learned with this interactive quiz

6 questions
6 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer