DEV Community

Ameni Nuretemo
Ameni Nuretemo

Posted on

Building KVM on Debian Linux as a Foundation for Experiments

  • Hi everyone. I'm building a "Home Lab" for my technical experiments. In this post, I'll share how to configure KVM and network bridging on Debian 13.

Configuration

  • Operating System: Debian GNU/Linux 13
  • Processor: 16 × AMD Ryzen 7 7700 8-Core Processor
  • Memory: 32 GiB of RAM
  • Graphics Processor: NVIDIA GeForce RTX 3050/PCIe/SSE2
  • Storage: 2TB SSD
  • Manufacturer: Micro-Star International Co., Ltd.
  • Product Name: MS-7E80

Verifying Virtualization

Virtualization requires specific CPU features. Please ensure they are enabled in your BIOS.

For Intel:

Intel VT-x
Intel Virtualization Technology

Enter fullscreen mode Exit fullscreen mode

For AMD:

SVM
AMD-V

Enter fullscreen mode Exit fullscreen mode

Set these to Enabled.

Confirm that SVM Mode is Enabled in the BIOS. To verify this within Linux, run:

egrep -c '(vmx|svm)' /proc/cpuinfo

Enter fullscreen mode Exit fullscreen mode

Since I am using an AMD processor, a value of 1 or higher indicates virtualization is supported. In my case, it returned 16, which corresponds to the number of available logical CPUs.

Setting the Working Directory

I have established a rule to create a vm directory in the $HOME folder to house all virtual machines.

mkdir ~/vm

Enter fullscreen mode Exit fullscreen mode

Installing KVM + libvirt (The Standard Linux Approach)

Install KVM and the related libvirt packages:

sudo apt install qemu-kvm libvirt-daemon-system virt-manager
sudo adduser $USER libvirt

Enter fullscreen mode Exit fullscreen mode

Note: Since I added myself to the libvirt group, a logout and login are required for the changes to take effect.

The virtualization environment is now ready.

Additional Installations

While not strictly required, I am also installing bridge utilities and tools for creating virtual machines via the command line:

sudo apt install bridge-utils virtinst

Enter fullscreen mode Exit fullscreen mode

Testing

Let's create the first virtual machine. Download the Debian ISO from debian.org, create an iso folder within the vm directory, and store it there.

cd ~/vm
mkdir ./iso
mv ~/Downloads/debian-13.3.0-amd64-netinst.iso ~/vm/iso

Enter fullscreen mode Exit fullscreen mode

Setting Up the Network Bridge

We will configure a network bridge to simplify communication and management between servers.

Procedure Workflow:

  1. Create a bridge interface.
  2. Connect the physical NIC to the bridge.
  3. Migrate the IP configuration to the bridge.
  4. Restart the connection.

Verifying Network Status

Check the status of NetworkManager with the following command:

systemctl status NetworkManager

Enter fullscreen mode Exit fullscreen mode

If it is active, check the IP status:

ip a

Enter fullscreen mode Exit fullscreen mode

Your physical interface (e.g., enp****) will be displayed. We will convert this into a bridge.

1. Create the Bridge

sudo nmcli connection add type bridge ifname br0 con-name br0

Enter fullscreen mode Exit fullscreen mode

2. Connect Physical NIC to the Bridge

sudo nmcli connection add type bridge-slave ifname enp**** master br0
sudo nmcli connection up bridge-slave-enp****
sudo nmcli connection up br0

Enter fullscreen mode Exit fullscreen mode

3. Set the IP on the Bridge
I will reuse the current IP: 192.168.0.200/24.

Configuration:

sudo nmcli connection modify br0 ipv4.addresses 192.168.0.200/24
sudo nmcli connection modify br0 ipv4.gateway 192.168.0.1
sudo nmcli connection modify br0 ipv4.method manual

Enter fullscreen mode Exit fullscreen mode

DNS:

sudo nmcli connection modify br0 ipv4.dns 192.168.0.1

Enter fullscreen mode Exit fullscreen mode

4. Disable the Original Connection

sudo nmcli connection down enp****

Enter fullscreen mode Exit fullscreen mode

5. Activate the Bridge

sudo nmcli connection up br0

Enter fullscreen mode Exit fullscreen mode

Success Verification:
Run ip a. You should see br0 with the IP 192.168.0.200 and your physical NIC (e.g., enp11s0) listed with master br0.

Once this is complete, you can select network source = br0 when creating a VM in KVM, allowing the VM to obtain an IP (e.g., 192.168.0.x) directly on the local network.

Creating a VM

Launch the Virtual Machine Manager.

Allocate Memory and CPU.

Specify the Storage location (within the vm folder).

Specify the ISO image location.

Perform the Final Review and start the installation.

Installation Complete


The OS installation will now proceed.


Top comments (0)