Files
2024-11-04 18:48:51 +00:00

342 lines
20 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="en" data-content_root="../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Clear Linux* OS on KVM &#8212; Documentation for Clear Linux* project</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/bizstyle.css?v=5283bb3d" />
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css?v=76b2166b" />
<script src="../../_static/documentation_options.js?v=5929fcd5"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
<script src="../../_static/copybutton.js?v=a56c686a"></script>
<script src="../../_static/bizstyle.js"></script>
<link rel="canonical" href="https://clearlinux.github.io/clear-linux-documentation/get-started/virtual-machine-install/kvm.html" />
<link rel="icon" href="../../_static/favicon.ico"/>
<link rel="author" title="About these documents" href="../../about.html" />
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="Clear Linux* OS on Parallels* Desktop for Mac*" href="parallels.html" />
<link rel="prev" title="Clear Linux* OS on Microsoft Hyper-V*" href="hyper-v.html" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<!--[if lt IE 9]>
<script src="_static/css3-mediaqueries.js"></script>
<![endif]-->
</head><body>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="parallels.html" title="Clear Linux* OS on Parallels* Desktop for Mac*"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="hyper-v.html" title="Clear Linux* OS on Microsoft Hyper-V*"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">Documentation for Clear Linux* project</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Get started</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Clear Linux* OS on KVM</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="cl-attr-on-kvm">
<span id="kvm"></span><h1>Clear Linux* OS on KVM<a class="headerlink" href="#cl-attr-on-kvm" title="Link to this heading"></a></h1>
<p>This page explains how to run Clear Linux* OS in a virtualized environment using
<abbr title="Kernel-based Virtual Machine">KVM</abbr>.</p>
<nav class="contents local" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#install-qemu-kvm" id="id2">Install QEMU-KVM</a></p></li>
<li><p><a class="reference internal" href="#download-and-launch-the-virtual-machine-image" id="id3">Download and launch the virtual machine image</a></p></li>
<li><p><a class="reference internal" href="#optional-enable-ssh-access" id="id4">Optional: Enable SSH access</a></p></li>
<li><p><a class="reference internal" href="#optional-install-a-graphical-user-interface-gui" id="id5">Optional: Install a graphical user interface (GUI)</a></p></li>
</ul>
</nav>
<section id="install-qemu-kvm">
<h2><a class="toc-backref" href="#id2" role="doc-backlink">Install QEMU-KVM</a><a class="headerlink" href="#install-qemu-kvm" title="Link to this heading"></a></h2>
<ol class="arabic">
<li><p>Enable the <a class="reference external" href="https://www.intel.com/content/www/us/en/virtualization/virtualization-technology/intel-virtualization-technology.html">Intel® Virtualization Technology</a> (Intel® VT) and the
<a class="reference external" href="https://software.intel.com/en-us/articles/intel-virtualization-technology-for-directed-io-vt-d-enhancing-intel-platforms-for-efficient-virtualization-of-io-devices">Intel® Virtualization Technology for Directed I/O</a> (Intel® VT-d) in the
host machines BIOS.</p></li>
<li><p>Log in and open a terminal emulator.</p></li>
<li><p>Install <cite>QEMU*-KVM</cite> on the host machine. Below are some examples using
different distros:</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Host OS</p></th>
<th class="head"><p>Installation command</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Clear Linux OS</p></td>
<td><p><strong class="command">sudo swupd bundle-add kvm-host</strong></p></td>
</tr>
<tr class="row-odd"><td><p>Ubuntu* and Mint*</p></td>
<td><p><strong class="command">sudo apt-get install qemu-kvm</strong></p></td>
</tr>
<tr class="row-even"><td><p>Fedora</p></td>
<td><p><strong class="command">dnf install qemu-kvm</strong></p></td>
</tr>
</tbody>
</table>
</li>
</ol>
</section>
<section id="download-and-launch-the-virtual-machine-image">
<h2><a class="toc-backref" href="#id3" role="doc-backlink">Download and launch the virtual machine image</a><a class="headerlink" href="#download-and-launch-the-virtual-machine-image" title="Link to this heading"></a></h2>
<ol class="arabic">
<li><p>Download the latest pre-built Clear Linux OS KVM image file from
the <a class="reference external" href="https://cdn.download.clearlinux.org/image/">image</a> directory. Look for
<code class="docutils literal notranslate"><span class="pre">clear-&lt;version&gt;-kvm.img.xz</span></code>. You can also use this command:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>curl<span class="w"> </span>-o<span class="w"> </span>clear.img.xz<span class="w"> </span>https://cdn.download.clearlinux.org/image/<span class="k">$(</span>curl<span class="w"> </span>https://cdn.download.clearlinux.org/image/latest-images.json<span class="w"> </span><span class="p">|</span><span class="w"> </span>grep<span class="w"> </span>-o<span class="w"> </span><span class="s1">&#39;clear-[0-9]*-kvm.img.xz&#39;</span><span class="w"> </span><span class="p">|</span><span class="w"> </span>head<span class="w"> </span>-1<span class="k">)</span>
</pre></div>
</div>
</li>
<li><p>Uncompress the downloaded image:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>xz<span class="w"> </span>-dv<span class="w"> </span>clear.img.xz
</pre></div>
</div>
</li>
<li><p>Download the 3 OVMF files (<cite>OVMF.fd</cite>, <cite>OVMF_CODE.fd</cite>, <cite>OVMF_VARS.fd</cite>) that
provides UEFI support for virtual machines.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>curl<span class="w"> </span>-O<span class="w"> </span>https://cdn.download.clearlinux.org/image/OVMF.fd
curl<span class="w"> </span>-O<span class="w"> </span>https://cdn.download.clearlinux.org/image/OVMF_CODE.fd
curl<span class="w"> </span>-O<span class="w"> </span>https://cdn.download.clearlinux.org/image/OVMF_VARS.fd
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The default OVMF files from Clear Linux OS may not work for some non-Clear Linux OS distro
version(s). You may get an <cite>ASSERT</cite> in the <cite>debug.log</cite> file when
starting the VM. If you encounter this, use the distro-specific OVMF
files instead.</p>
</div>
</li>
<li><p>Download the <a class="reference external" href="https://cdn.download.clearlinux.org/image/start_qemu.sh">start_qemu.sh</a> script from the
<a class="reference external" href="https://cdn.download.clearlinux.org/image/">image</a> directory. This script
will launch the Clear Linux OS VM and provide console interaction within the same
terminal emulator window.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>curl<span class="w"> </span>-O<span class="w"> </span>https://cdn.download.clearlinux.org/image/start_qemu.sh
</pre></div>
</div>
</li>
<li><p>Start the Clear Linux OS KVM virtual machine:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>bash<span class="w"> </span>./start_qemu.sh<span class="w"> </span>clear.img
</pre></div>
</div>
</li>
<li><p>Log in as <code class="docutils literal notranslate"><span class="pre">root</span></code> user and set a new password.</p></li>
</ol>
</section>
<section id="optional-enable-ssh-access">
<h2><a class="toc-backref" href="#id4" role="doc-backlink">Optional: Enable SSH access</a><a class="headerlink" href="#optional-enable-ssh-access" title="Link to this heading"></a></h2>
<p>To interact with the Clear Linux OS VM remotely through SSH instead of the console it
was launched from, follow these steps.</p>
<ol class="arabic">
<li><p>Enable and configure SSH in the Clear Linux OS VM to allow root login as described in
<a class="reference internal" href="../../guides/network/openssh-server.html#openssh-server"><span class="std std-ref">Enable and configure SSH service</span></a>.</p></li>
<li><p>SSH into the Clear Linux OS VM using the port <cite>10022</cite>. This port number is set in
<code class="file docutils literal notranslate"><span class="pre">start_qemu.sh</span></code> and passed through to the SSH service running on port
22</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>ssh<span class="w"> </span>-p<span class="w"> </span><span class="m">10022</span><span class="w"> </span>root@&lt;ip-addr-of-kvm-host&gt;
</pre></div>
</div>
</li>
</ol>
</section>
<section id="optional-install-a-graphical-user-interface-gui">
<h2><a class="toc-backref" href="#id5" role="doc-backlink">Optional: Install a graphical user interface (GUI)</a><a class="headerlink" href="#optional-install-a-graphical-user-interface-gui" title="Link to this heading"></a></h2>
<p>To add <abbr title="GNOME Display Manager">GDM</abbr> to the Clear Linux OS VM, follow these steps:</p>
<ol class="arabic">
<li><p>Shutdown the active Clear Linux OS VM.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>poweroff
</pre></div>
</div>
</li>
<li><p>Install the Spice viewer on the localhost or remote system. Below are some
examples using different distros:</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Host OS</p></th>
<th class="head"><p>Installation command</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Clear Linux OS</p></td>
<td><p><strong class="command">sudo swupd bundle-add virt-viewer</strong></p></td>
</tr>
<tr class="row-odd"><td><p>Ubuntu* and Mint*</p></td>
<td><p><strong class="command">sudo apt-get install virt-viewer</strong></p></td>
</tr>
<tr class="row-even"><td><p>Fedora</p></td>
<td><p><strong class="command">dnf install virt-viewer</strong></p></td>
</tr>
</tbody>
</table>
</li>
<li><p>Modify the <code class="file docutils literal notranslate"><span class="pre">start_qemu.sh</span></code> script to increase memory (<cite>-m</cite>), add
graphics driver (<cite>-vga</cite>), and add Spice (<cite>-spice</cite>, <cite>-usb</cite>, and
<cite>-device</cite>) support.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">qemu-system-x86_64 \</span>
<span class="go"> -enable-kvm \</span>
<span class="gp"> $</span><span class="o">{</span>UEFI_BIOS<span class="o">}</span><span class="w"> </span><span class="se">\</span>
<span class="w"> </span>-smp<span class="w"> </span><span class="nv">sockets</span><span class="o">=</span><span class="m">1</span>,cpus<span class="o">=</span><span class="m">4</span>,cores<span class="o">=</span><span class="m">2</span><span class="w"> </span>-cpu<span class="w"> </span>host<span class="w"> </span><span class="se">\</span>
<span class="hll"><span class="w"> </span>-m<span class="w"> </span><span class="m">4096</span><span class="w"> </span><span class="se">\</span>
</span><span class="hll"><span class="w"> </span>-vga<span class="w"> </span>qxl<span class="w"> </span><span class="se">\</span>
</span><span class="hll"><span class="w"> </span>-nographic<span class="w"> </span><span class="se">\</span>
</span><span class="hll"><span class="w"> </span>-spice<span class="w"> </span><span class="nv">port</span><span class="o">=</span><span class="m">5924</span>,disable-ticketing<span class="w"> </span><span class="se">\</span>
</span><span class="hll"><span class="w"> </span>-usb<span class="w"> </span><span class="se">\</span>
</span><span class="hll"><span class="w"> </span>-device<span class="w"> </span>usb-tablet,bus<span class="o">=</span>usb-bus.0<span class="w"> </span><span class="se">\</span>
</span><span class="w"> </span>-drive<span class="w"> </span><span class="nv">file</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$IMAGE</span><span class="s2">&quot;</span>,if<span class="o">=</span>virtio,aio<span class="o">=</span>threads,format<span class="o">=</span>raw<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>-netdev<span class="w"> </span>user,id<span class="o">=</span>mynet0,hostfwd<span class="o">=</span>tcp::<span class="si">${</span><span class="nv">VMN</span><span class="si">}</span><span class="m">0022</span>-:22,hostfwd<span class="o">=</span>tcp::<span class="si">${</span><span class="nv">VMN</span><span class="si">}</span><span class="m">2375</span>-:2375<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>-device<span class="w"> </span>virtio-net-pci,netdev<span class="o">=</span>mynet0<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>-debugcon<span class="w"> </span>file:debug.log<span class="w"> </span>-global<span class="w"> </span>isa-debugcon.iobase<span class="o">=</span>0x402<span class="w"> </span><span class="nv">$@</span>
</pre></div>
</div>
</li>
<li><p>Due to changes in the <code class="file docutils literal notranslate"><span class="pre">start_qemu.sh</span></code> script from the previous step,
having previously used OVMF files will result in the VM not booting
properly and you returning to the UEFI shell. The easiest way to avoid this
is to delete the 3 OVMF files and reobtain originals before relaunching the
VM:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>rm<span class="w"> </span>-v<span class="w"> </span>OVMF*.fd
curl<span class="w"> </span>-O<span class="w"> </span>https://cdn.download.clearlinux.org/image/OVMF.fd
curl<span class="w"> </span>-O<span class="w"> </span>https://cdn.download.clearlinux.org/image/OVMF_CODE.fd
curl<span class="w"> </span>-O<span class="w"> </span>https://cdn.download.clearlinux.org/image/OVMF_VARS.fd
</pre></div>
</div>
</li>
<li><p>Increase the size of the VM by 10GB to accommodate the GDM installation:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>qemu-img<span class="w"> </span>resize<span class="w"> </span>-f<span class="w"> </span>raw<span class="w"> </span>clear-&lt;version&gt;-kvm.img<span class="w"> </span>+10G
</pre></div>
</div>
</li>
<li><p>Relaunch the Clear Linux OS VM:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>./start_qemu.sh<span class="w"> </span>clear.img
</pre></div>
</div>
</li>
<li><p>Determine the IP address of the host on which you will launch the VM.
Substitute &lt;ip-addr-of-kvm-host&gt; in the next step with this information.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>ip<span class="w"> </span>a
</pre></div>
</div>
</li>
<li><p>From the local host or remote system, open a new terminal emulator window
and connect into the Clear Linux OS VM using the Spice viewer:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>remote-viewer<span class="w"> </span>spice://&lt;ip-address-of-kvm-host&gt;:5924
</pre></div>
</div>
</li>
<li><p>Log in as <cite>root</cite> user into the Clear Linux OS VM.</p></li>
<li><p>Follow these steps from <a class="reference internal" href="../../guides/maintenance/increase-virtual-disk-size.html#increase-virtual-disk-size"><span class="std std-ref">Increase Virtual Disk Size of an Image</span></a> to resize the
partition of the virtual disk of the VM.</p></li>
<li><p>Add GDM to the Clear Linux OS VM:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>swupd<span class="w"> </span>bundle-add<span class="w"> </span>desktop-autostart
</pre></div>
</div>
</li>
<li><p>Reboot the Clear Linux OS VM to start GDM:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>reboot
</pre></div>
</div>
</li>
<li><p>Go through the GDM out-of-box experience (OOBE).</p></li>
<li><p>The default aspect ratio of the GDM GUI for the Clear Linux OS VM is 4:3. To change
it, use GDMs <cite>Devices &gt; Displays</cite> setting tool (located at the top-right
corner).</p></li>
</ol>
<p><em>Intel and the Intel logo are trademarks of Intel Corporation or its subsidiaries.</em></p>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../../index.html">
<img class="logo" src="../../_static/clearlinux.png" alt="Logo of Clear Linux* Project Docs"/>
</a></p>
<div>
<h3><a href="../../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Clear Linux* OS on KVM</a><ul>
<li><a class="reference internal" href="#install-qemu-kvm">Install QEMU-KVM</a></li>
<li><a class="reference internal" href="#download-and-launch-the-virtual-machine-image">Download and launch the virtual machine image</a></li>
<li><a class="reference internal" href="#optional-enable-ssh-access">Optional: Enable SSH access</a></li>
<li><a class="reference internal" href="#optional-install-a-graphical-user-interface-gui">Optional: Install a graphical user interface (GUI)</a></li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="hyper-v.html"
title="previous chapter">Clear Linux* OS on Microsoft Hyper-V*</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="parallels.html"
title="next chapter">Clear Linux* OS on Parallels* Desktop for Mac*</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../_sources/get-started/virtual-machine-install/kvm.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="parallels.html" title="Clear Linux* OS on Parallels* Desktop for Mac*"
>next</a> |</li>
<li class="right" >
<a href="hyper-v.html" title="Clear Linux* OS on Microsoft Hyper-V*"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">Documentation for Clear Linux* project</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" >Get started</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Clear Linux* OS on KVM</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2022 Intel Corporation. All Rights Reserved..
Last updated on Nov 04, 2024.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.3.
</div>
</body>
</html>