A Comprehensive Guide to Creating a Virtual Machine with Virt-Manager

This guide provides a new virtual machine (VM) using the virt-manager graphical interface. It covers connecting to a remote host, configuring the VM hardware for optimal performance, and walking through the OS installation.

1 Part 1: Prerequisites and Connection

Before creating a VM, you need to connect to your virtualization host and launch virt-manager. The host machine for this guide is running Gentoo Linux, and the client machine is a Mac.

1.1. For macOS Users: Install XQuartz

virt-manager is a graphical application. To run it from a remote Linux server and have the window appear on your Mac, you need an X server. XQuartz is the standard for this.

1.2. For Windows Users: Install MobaXterm

Windows users can use MobaXterm, which includes both an SSH client and a built-in X11 server, requiring no extra configuration.

1.3. Connect to Your Host via SSH

Open your terminal (or MobaXterm on Windows) and connect to your Linux virtualization host. The -X flag is crucial for enabling X11 forwarding.

# Replace 'user' with your username and 'your-server-address' with the host's IP or hostname
ssh -X user@your-server-address

1.4. Launch Virt-Manager

Once you are logged into the server, launch virt-manager.

virt-manager

The Virtual Machine Manager window should appear on your desktop after a few moments.

Troubleshooting - Force-Quitting a Stuck Session:

If virt-manager becomes unresponsive, you may need to force-quit it on the server.

# 1. Find the process ID (PID) of virt-manager
pgrep virt-manager
# 2. Terminate the process gracefully
pkill virt-manager
# 3. If it's still stuck, force-kill it
pkill -9 virt-manager

2 Part 2: The "Create New VM" Wizard

With virt-manager open, begin the creation process.

2.1. Start the Wizard

Go to File → New Virtual Machine.

2.2. Step 1: Choose Installation Method

Select Local install media (ISO image or CDROM). Click Forward.

2.3. Step 2: Locate Installation Media

Click Browse... → Browse Local to select your Ubuntu-24.04-live-server-amd64.iso file. Click Forward.

2.4. Step 3 & 4: Configure CPU and Memory

Allocate resources (e.g., 4096 MiB Memory, 4 CPUs). Click Forward.

2.5. Step 5: Configure Storage

Create a virtual hard disk (e.g., 250 GiB). Click Forward.

2.6. Step 6: Final Configuration

IMPORTANT: Check the box for Customize configuration before install.

Click Finish.

3 Part 3: Customizing Virtual Hardware

Fine-tune the settings for better performance and compatibility.

3.1. Overview Tab: Chipset and Firmware

3.2. Remove Unnecessary Devices

Select and remove the Tablet and Sound card.

3.3. Optimize Video Output

3.4. Final Review

Confirm your settings, then click Apply.

4 Part 4: Begin OS Installation

Click the Begin Installation button. A console window will open, and the VM will boot from the ISO.

5 Part 5: Ubuntu Server Installation Walkthrough

This section details the steps within the Ubuntu Server installer itself.

5.1. Network Configuration

Note: A static IP is configured because the Claremont Colleges firewall only allows SSH access (port 22) from specific, whitelisted addresses.

5.2. Storage Configuration

5.3. Profile Setup

Enter User Details: Your name: Nicholas Dodds, Server's name: cs181au, Username: ndodds. Choose a password and select Done.

5.4. Ubuntu Pro & SSH

5.5. Final Installation Steps

6 Part 6: Post-Installation & Verification

After rebooting, perform these final steps to ensure the VM is correctly configured.

6.1. Eject the Installation Media

The VM may try to boot from the ISO again. In virt-manager, go to the VM's hardware details:

6.2. Correct and Apply Network Configuration

Log into the newly installed server. The Ubuntu installer can sometimes fail to apply both IPv4 and IPv6 settings correctly. You must verify and fix the configuration file.

Use vim to edit the netplan configuration file:

sudo vim /etc/netplan/50-cloud-init.yaml

Verify the file contains the complete configuration for both IPv4 and IPv6. It should look exactly like this:

network:
  version: 2
  ethernets:
    ens3:
      addresses:
        - "134.173.42.103/24"
        - "2620:102:2001:902::103/64"
      nameservers:
        addresses:
          - 134.173.42.2
          - "2620:102:2001:902::2"
        search:
          - cs.hmc.edu
      routes:
        - to: default
          via: "2620:102:2001:902::1"
        - to: default
          via: "134.173.42.1"

Apply the corrected configuration to make it active:

sudo netplan apply

6.3. Final Network Test

To confirm that the network is working correctly, ping the gateway from within the VM:

ping 134.173.42.1

If successful, your virtual machine is now fully installed, configured, and ready for use.