<?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>VMware | A DevOps Blog</title><link>https://blog.bsdserver.nl/tag/vmware/</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/vmware/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title>Expand Disk Space on a VMware Linux VM Without Rebooting</title><link>https://blog.bsdserver.nl/expand-disk-space-on-a-vmware-linux-vm-without-rebooting/</link><guid isPermaLink="false">6981fa80bacee50001395b21</guid><dc:creator>Patrick de Ruiter</dc:creator><pubDate>Tue, 03 Feb 2026 13:50:38 +0000</pubDate><description>Say goodbye to downtime when you need more storage Running out of disk space on a production VM is stressful enough without the added headache of…</description><category>Linux</category><category>VMware</category><category>LVM</category><category>Sysadmin</category><media:content url="https://blog.bsdserver.nl/content/images/2026/02/resize-lvm-vmware.png" medium="image"/><content:encoded><![CDATA[<p>Running out of disk space on a production VM is stressful enough without scheduling a reboot as well. On VMware you can grow the virtual disk while the VM runs, but Linux keeps showing the old size.</p>
<p>This post walks through the whole process without a reboot: expand the VMDK in vSphere, make Linux recognise the new size, then grow the partition, LVM and filesystem.</p>
<h2 id="why-rescan-instead-of-reboot">Why rescan instead of reboot? <a class="anchor" data-pagefind-ignore href="#why-rescan-instead-of-reboot" aria-label="Link to this section">#</a></h2>
<p>When you grow a virtual disk, the hypervisor knows the new size immediately. The Linux guest does not: it still uses the size it read when the SCSI device was detected. A reboot re-reads it, but means downtime.</p>
<p>A SCSI rescan through <code>/sys</code> makes the kernel re-read the size of a running disk:</p>
<ul>
<li><strong>No downtime</strong>: the filesystem stays mounted and in use</li>
<li><strong>Seconds, not a maintenance window</strong></li>
<li><strong>Works for new disks too</strong>: a host rescan finds hot-added disks</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> to grow an existing disk or hot-add a new one on a running Linux VM.</li>
<li><strong>Skip it</strong> for shrinking. That needs different steps and carries more risk.</li>
</ul>
<h3 id="which-rescan">Which rescan? <a class="anchor" data-pagefind-ignore href="#which-rescan" aria-label="Link to this section">#</a></h3>
<table>
	<thead>
			<tr>
					<th>Situation</th>
					<th>What to rescan</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>You made an existing VMDK bigger</td>
					<td>The block device: <code>/sys/block/sdX/device/rescan</code></td>
			</tr>
			<tr>
					<td>You hot-added a new disk</td>
					<td>The SCSI host adapter: <code>/sys/class/scsi_host/hostN/scan</code></td>
			</tr>
	</tbody>
</table>
<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>
<table>
	<thead>
			<tr>
					<th>Layer</th>
					<th>Tool</th>
					<th>Job</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>Virtual disk (VMDK)</td>
					<td>vSphere Client</td>
					<td>Makes the disk bigger.</td>
			</tr>
			<tr>
					<td>Block device (<code>sda</code>)</td>
					<td><code>/sys</code> rescan</td>
					<td>Makes the kernel see the new size.</td>
			</tr>
			<tr>
					<td>Partition (<code>sda2</code>)</td>
					<td><code>growpart</code></td>
					<td>Grows the partition into the new space.</td>
			</tr>
			<tr>
					<td>LVM (if used)</td>
					<td><code>pvresize</code>, <code>lvextend</code></td>
					<td>Grows the PV, then the LV.</td>
			</tr>
			<tr>
					<td>Filesystem</td>
					<td><code>resize2fs</code> / <code>xfs_growfs</code></td>
					<td>Grows the filesystem into the bigger LV or partition.</td>
			</tr>
	</tbody>
</table>
<p>The flow: grow VMDK → rescan <code>sda</code> → <code>growpart</code> → <code>pvresize</code> → <code>lvextend</code> → <code>resize2fs</code> or <code>xfs_growfs</code> → <code>df -h</code> shows the space.</p>
<h2 id="the-scsi-rescan">The SCSI rescan <a class="anchor" data-pagefind-ignore href="#the-scsi-rescan" aria-label="Link to this section">#</a></h2>
<p>Linux lets you force the kernel to re-read disk information through the <code>/sys</code> filesystem. There are two scenarios.</p>
<h3 id="scenario-1-resizing-an-existing-disk">Scenario 1: Resizing an existing disk <a class="anchor" data-pagefind-ignore href="#scenario-1-resizing-an-existing-disk" aria-label="Link to this section">#</a></h3>
<p>After expanding an existing VMDK, tell that block device to refresh its size:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">echo</span> <span class="m">1</span> &gt; /sys/block/sda/device/rescan
</span></span></code></pre></div><ul>
<li>Replace <code>sda</code> with your actual device name (e.g., <code>sdb</code>, <code>sdc</code>).</li>
<li>The kernel re-reads where the disk ends and updates its size.</li>
</ul>
<p>Run these commands from a root shell (<code>sudo -i</code>):</p>
<ul>
<li><code>sudo echo 1 &gt; /sys/block/sda/device/rescan</code> fails with &ldquo;Permission denied&rdquo;: the redirect is done by your own, unprivileged shell.</li>
<li>Use <code>echo 1 | sudo tee /sys/block/sda/device/rescan</code> instead.</li>
</ul>
<h3 id="scenario-2-adding-a-new-disk">Scenario 2: Adding a new disk <a class="anchor" data-pagefind-ignore href="#scenario-2-adding-a-new-disk" aria-label="Link to this section">#</a></h3>
<p>After hot-adding a completely new disk, scan the SCSI host adapter for new devices:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">echo</span> <span class="s2">&#34;- - -&#34;</span> &gt; /sys/class/scsi_host/host0/scan
</span></span></code></pre></div><p>The three dashes are wildcards for channel, target and LUN. Not sure which <code>hostN</code> the disk is on? Scan all adapters at once:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">echo</span> <span class="s2">&#34;- - -&#34;</span> <span class="p">|</span> tee /sys/class/scsi_host/*/scan
</span></span></code></pre></div><h2 id="step-by-step-expanding-an-existing-disk">Step-by-step: expanding an existing disk <a class="anchor" data-pagefind-ignore href="#step-by-step-expanding-an-existing-disk" aria-label="Link to this section">#</a></h2>
<p>The complete workflow for growing an existing disk on a running Linux VM.</p>
<h3 id="step-1-expand-the-vmdk-in-vsphere">Step 1: Expand the VMDK in vSphere <a class="anchor" data-pagefind-ignore href="#step-1-expand-the-vmdk-in-vsphere" aria-label="Link to this section">#</a></h3>
<ol>
<li>Open the vSphere Client</li>
<li>Right-click your VM and select <strong>Edit Settings</strong></li>
<li>Find the hard disk you want to expand</li>
<li>Increase the size to your desired capacity</li>
<li>Click <strong>OK</strong></li>
</ol>
<h3 id="step-2-rescan-the-disk-in-linux">Step 2: Rescan the disk in Linux <a class="anchor" data-pagefind-ignore href="#step-2-rescan-the-disk-in-linux" aria-label="Link to this section">#</a></h3>
<p>Identify which device belongs to the disk you grew:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">lsblk
</span></span></code></pre></div><p>Trigger a rescan on that device:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">echo</span> <span class="m">1</span> &gt; /sys/block/sda/device/rescan
</span></span></code></pre></div><p>Verify the new size is detected. The disk size in the header should show the new value:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">fdisk -l /dev/sda
</span></span></code></pre></div><h3 id="step-3-expand-the-partition">Step 3: Expand the partition <a class="anchor" data-pagefind-ignore href="#step-3-expand-the-partition" aria-label="Link to this section">#</a></h3>
<p>The disk is bigger, but the partition still ends where it did. <code>growpart</code> (recommended) moves the end of a partition to the end of the disk, also while it is in use:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># Install growpart if needed (part of cloud-utils-growpart package)</span>
</span></span><span class="line"><span class="cl">yum install cloud-utils-growpart   <span class="c1"># RHEL/CentOS</span>
</span></span><span class="line"><span class="cl">apt install cloud-guest-utils      <span class="c1"># Debian/Ubuntu</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Grow the partition (partition 2 in this example)</span>
</span></span><span class="line"><span class="cl">growpart /dev/sda <span class="m">2</span>
</span></span></code></pre></div><ul>
<li><code>growpart /dev/sda 2</code>: disk and partition number, separated by a space.</li>
<li>Skip this step if the filesystem or PV sits directly on the disk without a partition.</li>
</ul>
<h3 id="step-4-resize-the-filesystem-or-lvm">Step 4: Resize the filesystem or LVM <a class="anchor" data-pagefind-ignore href="#step-4-resize-the-filesystem-or-lvm" aria-label="Link to this section">#</a></h3>
<p>What comes next depends on what sits on the partition:</p>
<table>
	<thead>
			<tr>
					<th>On the partition</th>
					<th>Steps</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>LVM</td>
					<td><code>pvresize</code>, <code>lvextend</code>, then grow the filesystem</td>
			</tr>
			<tr>
					<td>ext4 directly</td>
					<td><code>resize2fs /dev/sda2</code></td>
			</tr>
			<tr>
					<td>XFS directly</td>
					<td><code>xfs_growfs /mountpoint</code></td>
			</tr>
	</tbody>
</table>
<p><strong>For LVM setups</strong>, resize the physical volume first, so the volume group sees the extra space:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">pvresize /dev/sda2
</span></span></code></pre></div><p>Then give all free space to your logical volume:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">lvextend -l +100%FREE /dev/mapper/vg_name-lv_name
</span></span></code></pre></div><p><strong>For ext4 filesystems</strong>, grow the filesystem into the bigger LV or partition. Works while mounted:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">resize2fs /dev/mapper/vg_name-lv_name
</span></span><span class="line"><span class="cl"><span class="c1"># Or for a direct partition:</span>
</span></span><span class="line"><span class="cl">resize2fs /dev/sda2
</span></span></code></pre></div><p><strong>For XFS filesystems</strong> (common on RHEL/CentOS 7+). <code>xfs_growfs</code> takes the mount point, not the device:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">xfs_growfs /mountpoint
</span></span></code></pre></div><h3 id="step-5-verify-the-changes">Step 5: Verify the changes <a class="anchor" data-pagefind-ignore href="#step-5-verify-the-changes" aria-label="Link to this section">#</a></h3>
<p>Confirm everything worked:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">df -h
</span></span></code></pre></div><p>The filesystem should now report the expanded size.</p>
<h2 id="quick-reference-commands">Quick reference commands <a class="anchor" data-pagefind-ignore href="#quick-reference-commands" aria-label="Link to this section">#</a></h2>
<table>
	<thead>
			<tr>
					<th>Task</th>
					<th>Command</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>Rescan existing disk</td>
					<td><code>echo 1 &gt; /sys/block/sdX/device/rescan</code></td>
			</tr>
			<tr>
					<td>Scan for new disks</td>
					<td><code>echo &quot;- - -&quot; | tee /sys/class/scsi_host/*/scan</code></td>
			</tr>
			<tr>
					<td>Grow partition</td>
					<td><code>growpart /dev/sdX N</code></td>
			</tr>
			<tr>
					<td>Resize LVM PV</td>
					<td><code>pvresize /dev/sdXN</code></td>
			</tr>
			<tr>
					<td>Extend LV</td>
					<td><code>lvextend -l +100%FREE /dev/vg/lv</code></td>
			</tr>
			<tr>
					<td>Resize ext4</td>
					<td><code>resize2fs /dev/path</code></td>
			</tr>
			<tr>
					<td>Resize XFS</td>
					<td><code>xfs_growfs /mountpoint</code></td>
			</tr>
	</tbody>
</table>
<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>Permission denied</code> on the rescan</td>
					<td><code>sudo echo ... &gt;</code> runs the redirect without root. Use a root shell or <code>tee</code>.</td>
			</tr>
			<tr>
					<td><code>lsblk</code> still shows the old size</td>
					<td>Rescanned the wrong device. Check which <code>sdX</code> you grew.</td>
			</tr>
			<tr>
					<td>New disk does not appear</td>
					<td>Scanned the wrong host adapter. Scan all with <code>/sys/class/scsi_host/*/scan</code>.</td>
			</tr>
			<tr>
					<td><code>df</code> shows the old size</td>
					<td>Filesystem not grown yet. Run <code>resize2fs</code> or <code>xfs_growfs</code>.</td>
			</tr>
	</tbody>
</table>
<h2 id="important-caveats">Important caveats <a class="anchor" data-pagefind-ignore href="#important-caveats" aria-label="Link to this section">#</a></h2>
<ul>
<li><strong>Shrinking is different</strong>: this process is for <em>expanding</em> disks only.</li>
<li><strong>Backups first</strong>: always have a backup before modifying disk structures, even if the procedure is well-tested.</li>
<li><strong>VMware Tools</strong>: ensure VMware Tools is installed and running for best results.</li>
</ul>
<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-disk-expand-online" rel="noopener">pderuiter/blog-disk-expand-online</a>. It uses a Proxmox VM instead of vSphere (the rescan works the same), puts LVM on one data disk and XFS on another, and after you grow the disks with <code>terraform apply</code> the playbook does steps 2 to 4 (rescan, growpart, pvresize/lvextend, resize2fs or xfs_growfs) without a reboot; run <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>Linux caches the disk size; the <code>/sys</code> rescan forces a refresh. Combine that with VMware&rsquo;s hot-expand and you grow storage on a running VM:</p>
<ol>
<li>Grow the VMDK</li>
<li>Rescan the device</li>
<li><code>growpart</code></li>
<li><code>pvresize</code> and <code>lvextend</code> (LVM only)</li>
<li>Grow the filesystem</li>
</ol>
<p>Adding a disk instead of growing one? See <a href="https://blog.bsdserver.nl/expanding-disk-space-on-lvm-a-step-by-step-guide/">Expanding Disk Space on LVM: A Step-by-Step Guide</a>.</p>
]]></content:encoded></item></channel></rss>