You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aney.co.uk/guides/setup-qemu-kvm.html

94 lines
4.2 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="keywords" content="Blog, articles, template, guide, KVM, QEMU, virtualisation">
<meta name="author" content="Nathan (Aney) Steel">
<meta name="theme-color" content="white">
<meta name="theme-color" content="black">
<link rel="stylesheet" type="text/css" href="/main.css">
<link rel="icon" type="image/png" href="/images/favicon.svg">
<title>Setup QEMU/KVM virtualisation</title>
</head>
<body>
<header>
<a href="#main" class="vh">Jump directly to main content</a>
<h1>Setup QEMU/KVM virtualisation</h1>
<input id="burger-toggle" type="checkbox"/>
<label class="burger-container" for="burger-toggle"><div class="burger"></div><span class="sr">Burger menu</span></label>
<hr/>
<nav>
<a href="/">home</a>
<a href="/about.html">about</a>
<a href="/projects.html">projects</a>
<a href="/blog/">blog</a>
<a href="/sitemap.html">misc</a>
<a href="/support.html">support</a>
</nav>
<hr/>
</header>
<main id="main">
<section>
<p class="intro">Virtualisation is the act of creating a virtualised computer (guest), inside another computer (the host) by sharing the hardware. This allows a single host the ability to run all your services, whilst keeping a level of <a href="/guides/vm-seperation-of-concerns">SoC</a>.</p>
<h2>Enable in the BIOS</h2>
<p>To run virtual machines, certain flags in the bios need to be set. If you don't want to bring down an existing server to check, then check the next section first.</p>
<ul>
<li>Reboot your PC</li>
<li>At the BIOS splashscreen, press your motherboard's prefered key (typically <kbd>ESC</kbd>, <kbd>F3</kbd>, or <kbd>F12</kbd>).</li>
<li>Find and enable the virtualisation setting(s).
<ul>
<li>One of VT-x, AMD-V, SVM, or Vanderpool.</li>
<li>One of Intel VT-d, or AMD IOMMU (if available)</li>
</ul>
</li>
</ul>
<h2>Check Virtualisation is enabled</h2>
<p>Double check to make sure your server can be used for virtualisation, if you've enabled it in the BIOS it should be good. Just run one of the following command</p>
<pre><code>lscpu | grep 'Virtualization'</code></pre>
<pre><code>grep -E --color '(vmx|svm)' /proc/cpuinfo</code></pre>
<h2>Install the packages</h2>
<p>The easiest part, just copy and paste the below to install the required packages.</p>
<pre><code>sudo apt install qemu-kvm libvirt-clients libvirt-daemon libvirt-daemon-system virtinst</code></pre>
<h2>Sessions</h2>
<p>There are two different session types for VMs, user, and system sessions. If you are using a desktop, and intend to virtualise other desktop OSs I recommend user sessions. If you're setting up a server hypervisor, then use System sessions.</p>
<h3>User Session</h3>
<p>A user session VM is what I recommend for personal PCs, laptops, etc. as it's the best option for desktop virtualisation (e.g. a Kali install for l33t hackers).</p>
<h4>Add user to group</h4>
<pre><code>sudo adduser $USER libvirt</code></pre>
<h4>Enable default network</h4>
<p>Check the name of your default network (typically just 'default').</p>
<pre><code>sudo virsh net-list --all</code></pre>
<p>Enable the network.</p>
<pre><code>sudo virsh net-start default</code></pre>
<p>(Optionally) Set it to turn on with system boot.</p>
<pre><code>sudo virsh net-autostart default</code></pre>
<h3>System Session</h3>
<p>For now all that's needed to know is that you run sudo before any virsh commands, and that the VMs will launch with root permissions.</p>
<h2>Extra</h2>
<p><a href="/guides/setup-kvm-bridge.html">Setup bridge adapter for KVM</a></p>
<p><a href="/guides/kvm-optimisation.html">Optimisations for KVM Virtual Machines</a></p>
</section>
</main>
<footer>
<hr/>
<p>Written by <a href="https://aney.co.uk" target="_blank" rel="noopener">@aney</a> with <a href="https://danluu.com/web-bloat/" target="_blank" rel="noopener">web bloat</a> in mind | <a href="https://github.com/Aney/website" target="_blank" rel="noopener">Source Code</a></p>
</footer>
</body>
</html>