<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>How-to | A DevOps Blog</title><link>https://blog.bsdserver.nl/tag/howto/</link><description>Hands-on DevOps and homelab content: Kubernetes clusters, self-hosted services, CI/CD pipelines and infrastructure as code, by Patrick de Ruiter of We Build Your Cloud.</description><language>en</language><image><url>https://blog.bsdserver.nl/images/app-icon.svg</url><title>A DevOps Blog</title><link>https://blog.bsdserver.nl/</link></image><lastBuildDate>Wed, 18 Nov 2026 09:00:00 +0100</lastBuildDate><atom:link href="https://blog.bsdserver.nl/tag/howto/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title>Expanding Disk Space on LVM: A Step-by-Step Guide</title><link>https://blog.bsdserver.nl/expanding-disk-space-on-lvm-a-step-by-step-guide/</link><guid isPermaLink="false">693b514779eb54000160a487</guid><dc:creator>Patrick de Ruiter</dc:creator><pubDate>Thu, 11 Dec 2025 23:18:31 +0000</pubDate><description>Sometimes the required disk space for an application or service is greater than initially anticipated.</description><category>Linux</category><category>LVM</category><category>How-to</category><media:content url="https://blog.bsdserver.nl/content/images/2026/01/lvm-step-by-step.png" medium="image"/><content:encoded><![CDATA[<p>A filesystem runs full, and the server has no free space left. With LVM you add a disk and grow the filesystem while it stays mounted: no downtime, no reboot.</p>
<p>This post adds a new disk to an existing volume group and gives the space to <code>/var</code>, in six steps. It assumes your disks already use LVM. Without LVM it is still possible, but a lot harder.</p>
<h2 id="why-lvm-for-this">Why LVM for this? <a class="anchor" data-pagefind-ignore href="#why-lvm-for-this" aria-label="Link to this section">#</a></h2>
<ul>
<li><strong>Online</strong>: the filesystem stays mounted and in use the whole time</li>
<li><strong>Any disk</strong>: the new space does not have to sit next to the old space on the same disk</li>
<li><strong>Flexible</strong>: give the space to one logical volume now, keep the rest for later</li>
</ul>
<h3 id="when-to-use-it">When to use it <a class="anchor" data-pagefind-ignore href="#when-to-use-it" aria-label="Link to this section">#</a></h3>
<ul>
<li><strong>Use it</strong> when a VM or server gets an extra disk and an LVM filesystem needs the space.</li>
<li><strong>Skip it</strong> when the existing virtual disk can simply grow. Then grow that disk instead, see <a href="https://blog.bsdserver.nl/expand-disk-space-on-a-vmware-linux-vm-without-rebooting/">Expand Disk Space on a VMware Linux VM Without Rebooting</a>.</li>
</ul>
<h2 id="how-it-works">How it works <a class="anchor" data-pagefind-ignore href="#how-it-works" aria-label="Link to this section">#</a></h2>
<p>LVM stacks three layers between the disk and the filesystem:</p>
<table>
	<thead>
			<tr>
					<th>Layer</th>
					<th>Example here</th>
					<th>Job</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>Physical volume (PV)</td>
					<td><code>/dev/sdc</code></td>
					<td>A disk (or partition) prepared for LVM.</td>
			</tr>
			<tr>
					<td>Volume group (VG)</td>
					<td><code>ubuntu-vg</code></td>
					<td>Pool of space from all its PVs.</td>
			</tr>
			<tr>
					<td>Logical volume (LV)</td>
					<td><code>lv_var</code></td>
					<td>A slice of the pool that holds a filesystem.</td>
			</tr>
			<tr>
					<td>Filesystem</td>
					<td>ext4 on <code>/var</code></td>
					<td>Must be grown separately after the LV.</td>
			</tr>
	</tbody>
</table>
<p>The flow: new disk → <code>pvcreate</code> → <code>vgextend</code> (pool grows) → <code>lvextend</code> (LV grows) → <code>resize2fs</code> (filesystem grows) → <code>df</code> shows the space.</p>
<p>For more on PVs and VGs, see <a href="https://blog.bsdserver.nl/mastering-physical-volumes-and-volume-groups/">Mastering Physical Volumes and Volume Groups</a>.</p>
<h2 id="step-1-check-available-disks">Step 1: Check available disks <a class="anchor" data-pagefind-ignore href="#step-1-check-available-disks" aria-label="Link to this section">#</a></h2>
<p>Find the new, empty disk. <code>lsblk -fa</code> shows all block devices with their filesystem type, so you can see which disks are already in use:</p>
<pre tabindex="0"><code># lsblk -fa
NAME                   FSTYPE      LABEL UUID                                   FSAVAIL FSUSE% MOUNTPOINT
fd0
loop0                  squashfs                                                       0   100% /snap/core18/2344
sda
├─sda1
├─sda2                 LVM2_member       ycKirk-5Njf-jl0R-lGOE-jKbV-xmM5-dNEo0u
│ ├─ubuntu--vg-lv_boot ext4              09833142-b287-4b63-a06b-9ad220d3feb1      997M    16% /boot
│ ├─ubuntu--vg-lv_root ext4              8787c3f7-6651-4787-8fbb-907161694f75      8.1G    40% /
│ ├─ubuntu--vg-lv_var  ext4              7d71eec1-eec5-4083-b882-aa5256bfa98e      2.2G    72% /var
│ ├─ubuntu--vg-lv_swap swap              eb6d1ce5-46c3-4057-860b-ac9658b122df
│ └─ubuntu--vg-lv_home ext4              d8248abf-b466-480b-b962-3dfc00cc810e      5.9G     2% /home
└─sda3                 LVM2_member       Gzk1sQ-MTMY-tlr3-AH1g-2bAI-0O4V-SdkfXM
  ├─ubuntu--vg-lv_boot ext4              09833142-b287-4b63-a06b-9ad220d3feb1      997M    16% /boot
  └─ubuntu--vg-lv_root ext4              8787c3f7-6651-4787-8fbb-907161694f75      8.1G    40% /
sdb
sdc
sr0
</code></pre><ul>
<li><code>sda2</code> and <code>sda3</code> are <code>LVM2_member</code>: already part of the volume group.</li>
<li><code>sdb</code> and <code>sdc</code> have no partitions or filesystem: free to use.</li>
</ul>
<p>If a disk still has a partition table, <code>pvcreate</code> refuses it with this error:</p>
<pre tabindex="0"><code># pvcreate /dev/sdc
  Cannot use /dev/sdc: device is partitioned
</code></pre><p>Older LVM releases (2.02.x) report the same situation as <code>Device /dev/sdc excluded by a filter.</code></p>
<p>Remove the partition table with <code>wipefs</code>. <code>--all</code> removes every signature, <code>--backup</code> saves them to a file in your home directory first, so you can undo it:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">wipefs --all --backup /dev/sdc
</span></span></code></pre></div><p>Re-run <code>lsblk -fa</code> to check that the disk is now empty.</p>
<h2 id="step-2-initialize-the-empty-disk-as-a-physical-volume">Step 2: Initialize the empty disk as a physical volume <a class="anchor" data-pagefind-ignore href="#step-2-initialize-the-empty-disk-as-a-physical-volume" aria-label="Link to this section">#</a></h2>
<p><code>pvcreate</code> writes an LVM label on the disk, so a volume group can use it:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">pvcreate /dev/sdc
</span></span></code></pre></div><h2 id="step-3-check-which-volume-group-to-assign-the-disk-to">Step 3: Check which volume group to assign the disk to <a class="anchor" data-pagefind-ignore href="#step-3-check-which-volume-group-to-assign-the-disk-to" aria-label="Link to this section">#</a></h2>
<p><code>vgdisplay</code> lists the volume groups and their size and free space:</p>
<pre tabindex="0"><code>vgdisplay
</code></pre><pre tabindex="0"><code>  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  11
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                5
  Open LV               4
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               84.87 GiB
  PE Size               4.00 MiB
  Total PE              21727
  Alloc PE / Size       16583 / &lt;64.78 GiB
  Free  PE / Size       5144 / 20.09 GiB
  VG UUID               DD2SCh-4T1o-PhO9-sTNm-p72z-3zJg-2NNC0j
</code></pre><ul>
<li><code>VG Name</code>: the name you need in the next step.</li>
<li><code>Free PE / Size</code>: space in the pool that no LV uses yet.</li>
</ul>
<p>In this case there is only one volume group: &ldquo;ubuntu-vg&rdquo;.</p>
<h2 id="step-4-extend-the-volume-group-with-the-new-disk">Step 4: Extend the volume group with the new disk <a class="anchor" data-pagefind-ignore href="#step-4-extend-the-volume-group-with-the-new-disk" aria-label="Link to this section">#</a></h2>
<p><code>vgextend</code> adds the PV to the volume group. The pool grows by the size of the disk:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">vgextend ubuntu-vg /dev/sdc
</span></span></code></pre></div><p>The output looks something like this:</p>
<pre tabindex="0"><code>Volume group &#34;ubuntu-vg&#34; successfully extended
</code></pre><p>Check with <code>pvscan</code> that the PV now belongs to <code>ubuntu-vg</code>:</p>
<pre tabindex="0"><code>pvscan
</code></pre><pre tabindex="0"><code>PV /dev/sda2   VG ubuntu-vg       lvm2 [&lt;29.00 GiB / 0    free]
PV /dev/sda3   VG ubuntu-vg       lvm2 [&lt;5.88 GiB / 100.00 MiB free]
PV /dev/sdc    VG ubuntu-vg       lvm2 [&lt;50.00 GiB / &lt;50.00 GiB free]
Total: 3 [84.87 GiB] / in use: 3 [84.87 GiB] / in no VG: 0 [0   ]
</code></pre><p><code>/dev/sdc</code> is in <code>ubuntu-vg</code> with all of its space free.</p>
<h2 id="step-5-assign-the-extra-space-to-a-logical-volume">Step 5: Assign the extra space to a logical volume <a class="anchor" data-pagefind-ignore href="#step-5-assign-the-extra-space-to-a-logical-volume" aria-label="Link to this section">#</a></h2>
<p><code>lvextend</code> gives part of the free pool space to one LV. Here <code>/var</code> gets 30 GiB more:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">lvextend -L+30G /dev/ubuntu-vg/lv_var
</span></span></code></pre></div><table>
	<thead>
			<tr>
					<th>Option</th>
					<th>Use it for</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td><code>-L+30G</code></td>
					<td>Add a fixed amount; keeps the rest free for later.</td>
			</tr>
			<tr>
					<td><code>-L40G</code></td>
					<td>Set the total size of the LV.</td>
			</tr>
			<tr>
					<td><code>-l+100%FREE</code></td>
					<td>Give all free space in the VG to this LV.</td>
			</tr>
	</tbody>
</table>
<p>The output should be similar to this:</p>
<pre tabindex="0"><code>  Size of logical volume ubuntu-vg/lv_var changed from 10.00 GiB (2560 extents) to 40.00 GiB (10240 extents).
  Logical volume ubuntu-vg/lv_var successfully resized.
</code></pre><h2 id="step-6-resize-the-filesystem">Step 6: Resize the filesystem <a class="anchor" data-pagefind-ignore href="#step-6-resize-the-filesystem" aria-label="Link to this section">#</a></h2>
<p>The LV is bigger, but the filesystem on it is not yet. <code>resize2fs</code> grows an ext4 filesystem to fill the LV; it only needs the path of the LV and works while the filesystem is mounted:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">resize2fs /dev/ubuntu-vg/lv_var
</span></span></code></pre></div><p>Output should be something similar to this:</p>
<pre tabindex="0"><code>resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/ubuntu-vg/lv_var is mounted on /var; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 5
The filesystem on /dev/ubuntu-vg/lv_var is now 10485760 (4k) blocks long.
</code></pre><p><code>on-line resizing required</code> means it grew while mounted, which is what you want.</p>
<p><code>resize2fs</code> is for ext2/3/4 only:</p>
<table>
	<thead>
			<tr>
					<th>Filesystem</th>
					<th>Grow command</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>ext4</td>
					<td><code>resize2fs /dev/&lt;vg&gt;/&lt;lv&gt;</code></td>
			</tr>
			<tr>
					<td>XFS</td>
					<td><code>xfs_growfs &lt;mountpoint&gt;</code></td>
			</tr>
	</tbody>
</table>
<p>Check with <code>df</code> that the additional space is available to the filesystem:</p>
<pre tabindex="0"><code>df -h /var
</code></pre><pre tabindex="0"><code>Filesystem                     Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-lv_var   40G  7.1G   31G  19% /var
</code></pre><h2 id="troubleshooting">Troubleshooting <a class="anchor" data-pagefind-ignore href="#troubleshooting" aria-label="Link to this section">#</a></h2>
<table>
	<thead>
			<tr>
					<th>Symptom</th>
					<th>Cause / fix</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td><code>Cannot use /dev/sdc: device is partitioned</code></td>
					<td>Old partition table on the disk. Remove it with <code>wipefs</code> (step 1).</td>
			</tr>
			<tr>
					<td><code>Device /dev/sdc excluded by a filter.</code></td>
					<td>Same cause on older LVM, or an LVM filter in <code>lvm.conf</code> excludes the disk.</td>
			</tr>
			<tr>
					<td><code>Insufficient free space</code> on <code>lvextend</code></td>
					<td>Asked for more than <code>Free PE / Size</code>. Use a smaller size or <code>-l+100%FREE</code>.</td>
			</tr>
			<tr>
					<td><code>df</code> shows the old size</td>
					<td>The filesystem was not resized. Run step 6.</td>
			</tr>
	</tbody>
</table>
<h2 id="automate-it">Automate it <a class="anchor" data-pagefind-ignore href="#automate-it" aria-label="Link to this section">#</a></h2>
<p>The Ansible roles and Terraform code that build this setup are on GitHub: <a href="https://github.com/pderuiter/blog-lvm-expand" rel="noopener">pderuiter/blog-lvm-expand</a>. It creates a VM with two spare disks on Proxmox, builds a practice volume group on the first one and then adds the second disk and grows the logical volume and its filesystem as in the steps above; run <code>terraform apply</code> and then <code>ansible-playbook site.yml</code>.</p>
<h2 id="conclusion">Conclusion <a class="anchor" data-pagefind-ignore href="#conclusion" aria-label="Link to this section">#</a></h2>
<p>Expanding disk space on LVM works on a live system without downtime. The steps:</p>
<ol>
<li>Identify and prepare the new disk</li>
<li>Initialize it as a physical volume</li>
<li>Add it to the volume group</li>
<li>Extend the logical volume</li>
<li>Resize the filesystem</li>
</ol>
<p>Keep some free space in the volume group: next time you only need steps 5 and 6.</p>
]]></content:encoded></item></channel></rss>