mirror of
https://github.com/CloudNebulaProject/refraction-forger.git
synced 2026-04-10 13:20:40 +00:00
Complete guide covering KDL spec language, composability (base/include/profiles), distro support (OmniOS primary, Ubuntu secondary), output formats (QCOW2/OCI/tar), architecture, CLI reference, and migration guides from omnios-image-builder and Packer.
327 lines
16 KiB
HTML
327 lines
16 KiB
HTML
<!DOCTYPE HTML>
|
|
<html lang="en" class="light sidebar-visible" dir="ltr">
|
|
<head>
|
|
<!-- Book generated using mdBook -->
|
|
<meta charset="UTF-8">
|
|
<title>QCOW2 VM Images - Refraction Forger</title>
|
|
|
|
|
|
<!-- Custom HTML head -->
|
|
|
|
<meta name="description" content="">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="theme-color" content="#ffffff">
|
|
|
|
<link rel="icon" href="../favicon.svg">
|
|
<link rel="shortcut icon" href="../favicon.png">
|
|
<link rel="stylesheet" href="../css/variables.css">
|
|
<link rel="stylesheet" href="../css/general.css">
|
|
<link rel="stylesheet" href="../css/chrome.css">
|
|
<link rel="stylesheet" href="../css/print.css" media="print">
|
|
|
|
<!-- Fonts -->
|
|
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
|
|
<link rel="stylesheet" href="../fonts/fonts.css">
|
|
|
|
<!-- Highlight.js Stylesheets -->
|
|
<link rel="stylesheet" id="highlight-css" href="../highlight.css">
|
|
<link rel="stylesheet" id="tomorrow-night-css" href="../tomorrow-night.css">
|
|
<link rel="stylesheet" id="ayu-highlight-css" href="../ayu-highlight.css">
|
|
|
|
<!-- Custom theme stylesheets -->
|
|
|
|
|
|
<!-- Provide site root and default themes to javascript -->
|
|
<script>
|
|
const path_to_root = "../";
|
|
const default_light_theme = "light";
|
|
const default_dark_theme = "navy";
|
|
window.path_to_searchindex_js = "../searchindex.js";
|
|
</script>
|
|
<!-- Start loading toc.js asap -->
|
|
<script src="../toc.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="mdbook-help-container">
|
|
<div id="mdbook-help-popup">
|
|
<h2 class="mdbook-help-title">Keyboard shortcuts</h2>
|
|
<div>
|
|
<p>Press <kbd>←</kbd> or <kbd>→</kbd> to navigate between chapters</p>
|
|
<p>Press <kbd>S</kbd> or <kbd>/</kbd> to search in the book</p>
|
|
<p>Press <kbd>?</kbd> to show this help</p>
|
|
<p>Press <kbd>Esc</kbd> to hide this help</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="body-container">
|
|
<!-- Work around some values being stored in localStorage wrapped in quotes -->
|
|
<script>
|
|
try {
|
|
let theme = localStorage.getItem('mdbook-theme');
|
|
let sidebar = localStorage.getItem('mdbook-sidebar');
|
|
|
|
if (theme.startsWith('"') && theme.endsWith('"')) {
|
|
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
|
|
}
|
|
|
|
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
|
|
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
|
|
}
|
|
} catch (e) { }
|
|
</script>
|
|
|
|
<!-- Set the theme before any content is loaded, prevents flash -->
|
|
<script>
|
|
const default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? default_dark_theme : default_light_theme;
|
|
let theme;
|
|
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
|
if (theme === null || theme === undefined) { theme = default_theme; }
|
|
const html = document.documentElement;
|
|
html.classList.remove('light')
|
|
html.classList.add(theme);
|
|
html.classList.add("js");
|
|
</script>
|
|
|
|
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
|
|
|
|
<!-- Hide / unhide sidebar before it is displayed -->
|
|
<script>
|
|
let sidebar = null;
|
|
const sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
|
|
if (document.body.clientWidth >= 1080) {
|
|
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
|
|
sidebar = sidebar || 'visible';
|
|
} else {
|
|
sidebar = 'hidden';
|
|
sidebar_toggle.checked = false;
|
|
}
|
|
if (sidebar === 'visible') {
|
|
sidebar_toggle.checked = true;
|
|
} else {
|
|
html.classList.remove('sidebar-visible');
|
|
}
|
|
</script>
|
|
|
|
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
|
|
<!-- populated by js -->
|
|
<mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox>
|
|
<noscript>
|
|
<iframe class="sidebar-iframe-outer" src="../toc.html"></iframe>
|
|
</noscript>
|
|
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
|
|
<div class="sidebar-resize-indicator"></div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div id="page-wrapper" class="page-wrapper">
|
|
|
|
<div class="page">
|
|
<div id="menu-bar-hover-placeholder"></div>
|
|
<div id="menu-bar" class="menu-bar sticky">
|
|
<div class="left-buttons">
|
|
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
|
|
<i class="fa fa-bars"></i>
|
|
</label>
|
|
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
|
|
<i class="fa fa-paint-brush"></i>
|
|
</button>
|
|
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
|
|
<li role="none"><button role="menuitem" class="theme" id="default_theme">Auto</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
|
|
</ul>
|
|
<button id="search-toggle" class="icon-button" type="button" title="Search (`/`)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="/ s" aria-controls="searchbar">
|
|
<i class="fa fa-search"></i>
|
|
</button>
|
|
</div>
|
|
|
|
<h1 class="menu-title">Refraction Forger</h1>
|
|
|
|
<div class="right-buttons">
|
|
<a href="../print.html" title="Print this book" aria-label="Print this book">
|
|
<i id="print-button" class="fa fa-print"></i>
|
|
</a>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="search-wrapper" class="hidden">
|
|
<form id="searchbar-outer" class="searchbar-outer">
|
|
<div class="search-wrapper">
|
|
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
|
|
<div class="spinner-wrapper">
|
|
<i class="fa fa-spinner fa-spin"></i>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
<div id="searchresults-outer" class="searchresults-outer hidden">
|
|
<div id="searchresults-header" class="searchresults-header"></div>
|
|
<ul id="searchresults">
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
|
|
<script>
|
|
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
|
|
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
|
|
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
|
|
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
|
|
});
|
|
</script>
|
|
|
|
<div id="content" class="content">
|
|
<main>
|
|
<h1 id="qcow2-vm-images"><a class="header" href="#qcow2-vm-images">QCOW2 VM Images</a></h1>
|
|
<p>QCOW2 (QEMU Copy-On-Write v2) is the primary output format for bootable virtual machine images.</p>
|
|
<h2 id="how-qcow2-targets-work"><a class="header" href="#how-qcow2-targets-work">How QCOW2 Targets Work</a></h2>
|
|
<p>Phase 2 for a QCOW2 target follows this sequence:</p>
|
|
<ol>
|
|
<li><strong>Create a raw disk</strong> of the specified size</li>
|
|
<li><strong>Attach via loopback device</strong> (or equivalent)</li>
|
|
<li><strong>Create filesystem</strong>:
|
|
<ul>
|
|
<li><strong>ZFS</strong>: Create pool → create boot environment dataset → mount</li>
|
|
<li><strong>ext4</strong>: Partition disk → format → mount</li>
|
|
</ul>
|
|
</li>
|
|
<li><strong>Populate</strong> from Phase 1 rootfs (copy files into mounted filesystem)</li>
|
|
<li><strong>Install bootloader</strong> (UEFI or GRUB)</li>
|
|
<li><strong>Finalize</strong>:
|
|
<ul>
|
|
<li>ZFS: Set bootfs property → unmount → export pool</li>
|
|
<li>ext4: Unmount</li>
|
|
</ul>
|
|
</li>
|
|
<li><strong>Detach</strong> loopback device</li>
|
|
<li><strong>Convert</strong> raw disk to QCOW2 via <code>qemu-img convert</code></li>
|
|
</ol>
|
|
<h2 id="zfs-based-images-illumos"><a class="header" href="#zfs-based-images-illumos">ZFS-Based Images (illumos)</a></h2>
|
|
<p>ZFS is the default and recommended filesystem for OmniOS images:</p>
|
|
<pre><code class="language-kdl">target "vm" kind="qcow2" {
|
|
disk-size "2G"
|
|
bootloader "uefi"
|
|
filesystem "zfs"
|
|
pool {
|
|
property name="ashift" value="12"
|
|
}
|
|
}
|
|
</code></pre>
|
|
<h3 id="zfs-pool-details"><a class="header" href="#zfs-pool-details">ZFS Pool Details</a></h3>
|
|
<p>During build, Forger creates a uniquely-named ZFS pool (e.g., <code>forgebuild_12345</code>) to avoid conflicts with existing pools on the build host. After export, the pool is named <code>rpool</code> in the final image.</p>
|
|
<h3 id="pool-properties"><a class="header" href="#pool-properties">Pool Properties</a></h3>
|
|
<pre><code class="language-kdl">pool {
|
|
property name="ashift" value="12"
|
|
}
|
|
</code></pre>
|
|
<ul>
|
|
<li><strong><code>ashift=12</code></strong>: 4KB sector alignment. Use this for modern storage and virtual disks.</li>
|
|
<li>Additional ZFS pool properties can be set using the same syntax.</li>
|
|
</ul>
|
|
<h3 id="boot-environments"><a class="header" href="#boot-environments">Boot Environments</a></h3>
|
|
<p>ZFS images use boot environments (BEs), a core illumos concept. The image contains a single BE that becomes the default boot target. On first boot, the system can create new BEs for upgrades, allowing rollback to previous states.</p>
|
|
<h2 id="ext4-based-images-linux"><a class="header" href="#ext4-based-images-linux">ext4-Based Images (Linux)</a></h2>
|
|
<p>ext4 is the default filesystem for Ubuntu images:</p>
|
|
<pre><code class="language-kdl">target "vm" kind="qcow2" {
|
|
disk-size "8G"
|
|
bootloader "grub-efi-amd64-bin"
|
|
filesystem "ext4"
|
|
}
|
|
</code></pre>
|
|
<p>The disk is partitioned with an EFI System Partition and a root partition formatted as ext4.</p>
|
|
<h2 id="disk-sizing"><a class="header" href="#disk-sizing">Disk Sizing</a></h2>
|
|
<p>Specify the disk size as a string with a unit suffix:</p>
|
|
<pre><code class="language-kdl">disk-size "2G" // 2 gigabytes
|
|
disk-size "2000M" // 2000 megabytes
|
|
disk-size "8G" // 8 gigabytes
|
|
</code></pre>
|
|
<p>Choose a size that accommodates your installed packages plus reasonable free space. Typical sizes:</p>
|
|
<ul>
|
|
<li>Minimal OmniOS: 2G</li>
|
|
<li>OmniOS with development tools: 4-8G</li>
|
|
<li>Ubuntu with build tools: 8G</li>
|
|
</ul>
|
|
<h2 id="bootloader-options"><a class="header" href="#bootloader-options">Bootloader Options</a></h2>
|
|
<div class="table-wrapper"><table><thead><tr><th>Value</th><th>Platform</th><th>Description</th></tr></thead><tbody>
|
|
<tr><td><code>uefi</code></td><td>illumos</td><td>Native UEFI boot (recommended for OmniOS)</td></tr>
|
|
<tr><td><code>grub</code></td><td>illumos</td><td>Legacy GRUB (BIOS boot)</td></tr>
|
|
<tr><td><code>grub-efi-amd64-bin</code></td><td>Ubuntu</td><td>GRUB EFI for x86_64 Linux</td></tr>
|
|
</tbody></table>
|
|
</div>
|
|
<h2 id="auto-push"><a class="header" href="#auto-push">Auto-Push</a></h2>
|
|
<p>QCOW2 images can be automatically pushed to an OCI registry as artifacts:</p>
|
|
<pre><code class="language-kdl">target "vm" kind="qcow2" {
|
|
disk-size "8G"
|
|
bootloader "uefi"
|
|
filesystem "zfs"
|
|
push-to "ghcr.io/myorg/omnios-image:latest"
|
|
}
|
|
</code></pre>
|
|
<p>The QCOW2 file is wrapped as an OCI artifact with custom media types (<code>application/vnd.cloudnebula.qcow2.*</code>) and pushed to the registry. This allows distributing VM images through container registries.</p>
|
|
<h2 id="deploying-qcow2-images"><a class="header" href="#deploying-qcow2-images">Deploying QCOW2 Images</a></h2>
|
|
<p>QCOW2 images work with:</p>
|
|
<ul>
|
|
<li><strong>QEMU/KVM</strong>: Direct use (<code>qemu-system-x86_64 -drive file=image.qcow2,format=qcow2</code>)</li>
|
|
<li><strong>libvirt/virt-manager</strong>: Import as existing disk</li>
|
|
<li><strong>Proxmox</strong>: Upload to storage, create VM from disk</li>
|
|
<li><strong>Cloud platforms</strong>: Convert to platform-specific format if needed</li>
|
|
</ul>
|
|
<p>To convert to raw (for AWS, DigitalOcean, etc.):</p>
|
|
<pre><code class="language-bash">qemu-img convert -f qcow2 -O raw image.qcow2 image.raw
|
|
</code></pre>
|
|
|
|
</main>
|
|
|
|
<nav class="nav-wrapper" aria-label="Page navigation">
|
|
<!-- Mobile navigation buttons -->
|
|
<a rel="prev" href="../distros/adding-distro.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
<a rel="next prefetch" href="../formats/oci.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
|
|
<div style="clear: both"></div>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
|
|
<nav class="nav-wide-wrapper" aria-label="Page navigation">
|
|
<a rel="prev" href="../distros/adding-distro.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
<a rel="next prefetch" href="../formats/oci.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
window.playground_copyable = true;
|
|
</script>
|
|
|
|
|
|
<script src="../elasticlunr.min.js"></script>
|
|
<script src="../mark.min.js"></script>
|
|
<script src="../searcher.js"></script>
|
|
|
|
<script src="../clipboard.min.js"></script>
|
|
<script src="../highlight.js"></script>
|
|
<script src="../book.js"></script>
|
|
|
|
<!-- Custom JS scripts -->
|
|
|
|
|
|
|
|
</div>
|
|
</body>
|
|
</html>
|