Skip to content

Latest commit

 

History

History
33 lines (21 loc) · 1.2 KB

File metadata and controls

33 lines (21 loc) · 1.2 KB

KVM Toggle Script

A simple bash script to quickly enable or disable KVM (Kernel-based Virtual Machine) on Linux systems. Perfect for switching between Docker Desktop (which needs KVM) and VirtualBox (which conflicts with KVM).

Why I Made This

I kept running into issues when trying to use VirtualBox while Docker Desktop was running. Both virtualization solutions don't play well together because they both need exclusive access to virtualization features. This script lets me quickly toggle KVM on for Docker or off for VirtualBox without manually unloading kernel modules.

How to Use

  1. Save the script as kvm-toggle.sh

  2. Make it executable: chmod +x kvm-toggle.sh

  3. Run it with either:

    ./kvm-toggle.sh on   # Turns KVM ON (for Docker Desktop)
    ./kvm-toggle.sh off  # Turns KVM OFF (for VirtualBox)

What It Does

  • When turning OFF:

    • Stops Docker Desktop processes
    • Unloads KVM kernel modules (kvm_intel or kvm_amd)
  • When turning ON:

    • Loads the appropriate KVM module for your CPU
    • Restarts Docker Desktop in the background
  • sudo privileges (for loading/unloading kernel modules)

That's it! Simple solution to a frustrating virtualization conflict.