Files
clear-linux-documentation/guides/maintenance/increase-virtual-disk-size.html
2024-11-04 18:48:51 +00:00

306 lines
17 KiB
HTML

<!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>Increase Virtual Disk Size of an Image &#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/guides/maintenance/increase-virtual-disk-size.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 Amazon Web Services*" href="../../get-started/cloud-install/aws-web.html" />
<link rel="prev" title="Clear Linux* OS on VMware* ESXi" href="../../get-started/virtual-machine-install/vmware-esxi-install-cl.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="../../get-started/cloud-install/aws-web.html" title="Clear Linux* OS on Amazon Web Services*"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="../../get-started/virtual-machine-install/vmware-esxi-install-cl.html" title="Clear Linux* OS on VMware* ESXi"
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="../../get-started/index.html" accesskey="U">Get started</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Increase Virtual Disk Size of an Image</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="increase-virtual-disk-size-of-an-image">
<span id="increase-virtual-disk-size"></span><h1>Increase Virtual Disk Size of an Image<a class="headerlink" href="#increase-virtual-disk-size-of-an-image" title="Link to this heading"></a></h1>
<p>Clear Linux* OS pre-built images come in different sizes, ranging from 300 MB to 20
GB. This guide describes how to increase the disk size of your pre-built
image if you need more capacity. We will use the <a class="reference internal" href="../../get-started/virtual-machine-install/kvm.html#kvm"><span class="std std-ref">KVM image</span></a> as
an example to demonstrate the process of increasing disk size and expanding
the last partition to take up the added space.</p>
<nav class="contents local" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#determine-disk-size-and-list-of-partitions" id="id5">Determine disk size and list of partitions</a></p></li>
<li><p><a class="reference internal" href="#id1" id="id6">Increase virtual disk size</a></p></li>
</ul>
</nav>
<section id="determine-disk-size-and-list-of-partitions">
<h2><a class="toc-backref" href="#id5" role="doc-backlink">Determine disk size and list of partitions</a><a class="headerlink" href="#determine-disk-size-and-list-of-partitions" title="Link to this heading"></a></h2>
<p>There are two methods to find the disk size and the list of partitions of
a pre-built Clear Linux OS image.</p>
<section id="method-1-use-lsblk-on-the-vm">
<h3>Method 1: Use <strong class="command">lsblk</strong> on the VM<a class="headerlink" href="#method-1-use-lsblk-on-the-vm" title="Link to this heading"></a></h3>
<p>The first method is to boot up your VM and execute the <strong class="command">lsblk</strong>
command as shown below:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>lsblk
</pre></div>
</div>
<p>An example output of the <strong class="command">lsblk</strong> command:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT</span>
<span class="go">fd0 2:0 1 4K 0 disk</span>
<span class="go">sr0 11:0 1 1024M 0 rom</span>
<span class="hll"><span class="go">vda 254:0 0 8.6G 0 disk</span>
</span><span class="go">├─vda1 254:1 0 510M 0 part</span>
<span class="go">├─vda2 254:2 0 33M 0 part [SWAP]</span>
<span class="hll"><span class="go">└─vda3 254:3 0 8G 0 part /</span>
</span></pre></div>
</div>
<p>An example of this can also be seen in Figure 1.</p>
</section>
<section id="method-2-look-at-the-image-configuration-yaml-file">
<h3>Method 2: Look at the image configuration YAML file<a class="headerlink" href="#method-2-look-at-the-image-configuration-yaml-file" title="Link to this heading"></a></h3>
<p>The second method to look at the image configuration YAML file that was
used to produce the image.</p>
<p>For example, to find the size of the KVM image version number 31880,
follow these steps:</p>
<ol class="arabic">
<li><p>Go to the <a class="reference external" href="https://cdn.download.clearlinux.org/releases/">releases</a> repository.</p></li>
<li><p>Drill down into the <cite>31880 &gt; clear &gt; config &gt; image</cite> directory.</p></li>
<li><p>Download and open the <code class="file docutils literal notranslate"><span class="pre">kvm.yaml</span></code> file.</p></li>
<li><p>Locate the <cite>targetMedia</cite> section.</p>
<p>The example shows a total disk size of 8.54 GB, 512 MB for the EFI
partition, 32 MB for the swap partition, and 8 GB for the root partition.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="linenos"> 1</span><span class="go">targetMedia:</span>
<span class="linenos"> 2</span><span class="go">- name: ${bdevice}</span>
<span class="hll"><span class="linenos"> 3</span><span class="go"> size: &quot;8.54G&quot;</span>
</span><span class="linenos"> 4</span><span class="go"> type: disk</span>
<span class="linenos"> 5</span><span class="go"> children:</span>
<span class="linenos"> 6</span><span class="go"> - name: ${bdevice}1</span>
<span class="linenos"> 7</span><span class="go"> fstype: vfat</span>
<span class="linenos"> 8</span><span class="go"> mountpoint: /boot</span>
<span class="hll"><span class="linenos"> 9</span><span class="go"> size: &quot;512M&quot;</span>
</span><span class="linenos">10</span><span class="go"> type: part</span>
<span class="linenos">11</span><span class="go"> - name: ${bdevice}2</span>
<span class="linenos">12</span><span class="go"> fstype: swap</span>
<span class="hll"><span class="linenos">13</span><span class="go"> size: &quot;32M&quot;</span>
</span><span class="linenos">14</span><span class="go"> type: part</span>
<span class="linenos">15</span><span class="go"> - name: ${bdevice}3</span>
<span class="linenos">16</span><span class="go"> fstype: ext4</span>
<span class="linenos">17</span><span class="go"> mountpoint: /</span>
<span class="hll"><span class="linenos">18</span><span class="go"> size: &quot;8G&quot;</span>
</span><span class="linenos">19</span><span class="go"> type: part</span>
</pre></div>
</div>
</li>
</ol>
</section>
</section>
<section id="id1">
<h2><a class="toc-backref" href="#id6" role="doc-backlink">Increase virtual disk size</a><a class="headerlink" href="#id1" title="Link to this heading"></a></h2>
<p>Before you can expand the last partition of your image, you must make
space available by increasing the virtual disk size. After that, you
can resize the last partition and finally resize the filesystem.
Follow these steps:</p>
<section id="id2">
<h3>Increase virtual disk size<a class="headerlink" href="#id2" title="Link to this heading"></a></h3>
<ol class="arabic simple">
<li><p>Shut down your VM.</p></li>
<li><p>Use the process defined by your hypervisor or cloud provider to increase
the virtual disk size of your Clear Linux OS VM.</p></li>
<li><p>Power up your VM.</p></li>
</ol>
</section>
<section id="resize-the-last-partition-of-the-virtual-disk">
<h3>Resize the last partition of the virtual disk<a class="headerlink" href="#resize-the-last-partition-of-the-virtual-disk" title="Link to this heading"></a></h3>
<ol class="arabic">
<li><p>Log in.</p></li>
<li><p>Open a terminal window.</p></li>
<li><p>Add the <strong class="command">storage-utils</strong> bundle to install the
<strong class="command">parted</strong> and <strong class="command">resize2fs</strong> tools.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>swupd<span class="w"> </span>bundle-add<span class="w"> </span>storage-utils
</pre></div>
</div>
</li>
<li><p>Launch the <strong class="command">parted</strong> tool.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>parted
</pre></div>
</div>
</li>
<li><p>In the <cite>parted</cite> tool, perform these steps:</p>
<ol class="loweralpha">
<li><p>Press <strong class="command">p</strong> to print the partitions table.</p></li>
<li><p>If the warning message below is displayed, enter <strong class="command">Fix</strong>.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">Warning: Not all of the space available to :file:`/dev/sda` appears</span>
<span class="go">to be used, you can fix the GPT to use all of the space (an extra ...</span>
<span class="go">blocks) or continue with the current setting?</span>
<span class="go">Fix/Ignore?</span>
</pre></div>
</div>
</li>
<li><p>Enter <strong class="command">resizepart &lt;partition number&gt;</strong> where
<em>&lt;partition number&gt;</em> is the number of the partition to modify.</p></li>
<li><p>Enter the new <cite>End</cite> size.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>If you want a partition to take up the remaining disk space, then
enter the total size of the disk. When you print the partitions
table with the <strong class="command">p</strong> command, the total disk size is shown
after the <span class="guilabel">Disk</span> label.</p>
<p>An example of this can be seen in Figure 1.</p>
</div>
</li>
<li><p>Enter <strong class="command">q</strong> to exit <cite>parted</cite> when you are finished resizing the
partition.</p>
<p>Figure 1 depicts the described steps to resize the partition of the
virtual disk from 8.5 GB to 30 GB.</p>
<figure class="dropshadow align-default" id="id3">
<a class="reference internal image-reference" href="../../_images/01-increase-virtual-disk-size.png"><img alt="Increase root partition size" src="../../_images/01-increase-virtual-disk-size.png" style="width: 1064.0px; height: 670.0px;" />
</a>
<figcaption>
<p><span class="caption-text">Figure 1: Increase root partition size</span><a class="headerlink" href="#id3" title="Link to this image"></a></p>
</figcaption>
</figure>
</li>
</ol>
</li>
</ol>
</section>
<section id="resize-the-filesystem">
<h3>Resize the filesystem<a class="headerlink" href="#resize-the-filesystem" title="Link to this heading"></a></h3>
<ol class="arabic">
<li><p>Enter <strong class="command">sudo resize2fs -p /dev/&lt;modified partition name&gt;</strong> where
<em>&lt;modified partition name&gt;</em> is the partition that was changed in the <cite>parted</cite>
tool.</p></li>
<li><p>Run <strong class="command">lsblk</strong> to verify that the filesystem size has increased.</p>
<p>Figure 2 depicts the described steps to resize the filesystem of the virtual
disk from 8.5 GB to 30 GB.</p>
<figure class="dropshadow align-default" id="id4">
<a class="reference internal image-reference" href="../../_images/02-increase-virtual-disk-size.png"><img alt="Increase root filesystem with resize2fs" src="../../_images/02-increase-virtual-disk-size.png" style="width: 1065.0px; height: 283.0px;" />
</a>
<figcaption>
<p><span class="caption-text">Figure 2: Increase root filesystem with <strong class="command">resize2fs</strong></span><a class="headerlink" href="#id4" title="Link to this image"></a></p>
</figcaption>
</figure>
</li>
</ol>
</section>
</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="#">Increase Virtual Disk Size of an Image</a><ul>
<li><a class="reference internal" href="#determine-disk-size-and-list-of-partitions">Determine disk size and list of partitions</a><ul>
<li><a class="reference internal" href="#method-1-use-lsblk-on-the-vm">Method 1: Use <strong class="command">lsblk</strong> on the VM</a></li>
<li><a class="reference internal" href="#method-2-look-at-the-image-configuration-yaml-file">Method 2: Look at the image configuration YAML file</a></li>
</ul>
</li>
<li><a class="reference internal" href="#id1">Increase virtual disk size</a><ul>
<li><a class="reference internal" href="#id2">Increase virtual disk size</a></li>
<li><a class="reference internal" href="#resize-the-last-partition-of-the-virtual-disk">Resize the last partition of the virtual disk</a></li>
<li><a class="reference internal" href="#resize-the-filesystem">Resize the filesystem</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="../../get-started/virtual-machine-install/vmware-esxi-install-cl.html"
title="previous chapter">Clear Linux* OS on VMware* ESXi</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="../../get-started/cloud-install/aws-web.html"
title="next chapter">Clear Linux* OS on Amazon Web Services*</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../_sources/guides/maintenance/increase-virtual-disk-size.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="../../get-started/cloud-install/aws-web.html" title="Clear Linux* OS on Amazon Web Services*"
>next</a> |</li>
<li class="right" >
<a href="../../get-started/virtual-machine-install/vmware-esxi-install-cl.html" title="Clear Linux* OS on VMware* ESXi"
>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="../../get-started/index.html" >Get started</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Increase Virtual Disk Size of an Image</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>