<?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/"><channel><title>Lvm on inetshell</title><link>https://inet.sh/en/tags/lvm/</link><description>Recent content in Lvm on inetshell</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sat, 26 Sep 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://inet.sh/en/tags/lvm/index.xml" rel="self" type="application/rss+xml"/><item><title>Grow a Linux VM disk online: rescan, growpart, pvresize, lvextend and xfs_growfs</title><link>https://inet.sh/en/posts/linux/grow-linux-vm-disk-online/</link><pubDate>Sat, 26 Sep 2026 00:00:00 +0000</pubDate><guid>https://inet.sh/en/posts/linux/grow-linux-vm-disk-online/</guid><description>You already enlarged the virtual disk on Proxmox, VMware or the cloud and inside the VM nothing changed. The four steps with no reboot: make the kernel see the new size (virtio-blk on its own; SCSI with a rescan), growpart for the partition, pvresize + lvextend -r if there is LVM, and resize2fs or xfs_growfs. With the usual errors: NOCHANGE, locale, partition that is not the last one.</description><content:encoded><![CDATA[<h2 id="tldr">TL;DR</h2>
<p>With the disk already enlarged on the hypervisor side (<code>qm resize 100 scsi0 +50G</code> on Proxmox, <em>Edit disk</em> on VMware, your cloud console):</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span><span class="lnt">13
</span><span class="lnt">14
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl"><span class="c1"># 1. Make the kernel see the new size (virtio-scsi/SATA; virtio-blk detects it alone)</span>
</span></span><span class="line"><span class="cl"><span class="nb">echo</span> <span class="m">1</span> &gt; /sys/class/block/sda/device/rescan
</span></span><span class="line"><span class="cl">lsblk /dev/sda
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># 2. Enlarge the partition (package cloud-guest-utils on Debian/Ubuntu, cloud-utils-growpart on RHEL)</span>
</span></span><span class="line"><span class="cl">growpart /dev/sda <span class="m">3</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># 3a. With LVM: PV, LV and filesystem</span>
</span></span><span class="line"><span class="cl">pvresize /dev/sda3
</span></span><span class="line"><span class="cl">lvextend -r -l +100%FREE /dev/ubuntu-vg/ubuntu-lv      <span class="c1"># -r: resize2fs or xfs_growfs depending on the fs</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># 3b. Without LVM</span>
</span></span><span class="line"><span class="cl">resize2fs /dev/sda3        <span class="c1"># ext4</span>
</span></span><span class="line"><span class="cl">xfs_growfs /               <span class="c1"># xfs: takes the mount point</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>No reboot. <code>df -h /</code> confirms.</p>
<h2 id="before-starting">Before starting</h2>
<ul>
<li><strong>Snapshot or backup on the hypervisor.</strong> Growing is safe; picking the wrong partition is not.</li>
<li><strong>Look at the layout</strong>: <code>lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS</code>. It shows the partition number, whether LVM sits underneath, and which filesystem you are dealing with.</li>
<li><strong>Names</strong>: virtio-blk is <code>/dev/vda</code>; virtio-scsi and SATA, <code>/dev/sda</code>; NVMe, <code>/dev/nvme0n1</code> with partitions <code>p1</code>, <code>p2</code>… (<code>growpart /dev/nvme0n1 1</code>).</li>
<li><strong>Sometimes the space is already there</strong>: Ubuntu Server creates the LV using only part of the VG. If <code>vgs</code> shows a large <code>VFree</code>, jump straight to <code>lvextend</code>.</li>
</ul>
<h2 id="1-make-the-kernel-see-the-new-disk">1. Make the kernel see the new disk</h2>
<table>
  <thead>
      <tr>
          <th>Bus</th>
          <th>What to do</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>virtio-blk (<code>vda</code>)</td>
          <td>Nothing: <code>dmesg | tail</code> shows <code>[vda] new size: …</code></td>
      </tr>
      <tr>
          <td>virtio-scsi, SATA, IDE (<code>sda</code>)</td>
          <td><code>echo 1 &gt; /sys/class/block/sda/device/rescan</code></td>
      </tr>
      <tr>
          <td>New disk (not grown)</td>
          <td><code>echo &quot;- - -&quot; &gt; /sys/class/scsi_host/host0/scan</code></td>
      </tr>
      <tr>
          <td>NVMe in the cloud</td>
          <td>Usually shows up on its own within a minute; if not, <code>echo 1 &gt; /sys/class/nvme/nvme0/rescan_controller</code></td>
      </tr>
  </tbody>
</table>
<p><code>lsblk</code> must show the new size on the disk before moving on; otherwise <code>growpart</code> will say <code>NOCHANGE</code>.</p>
<h2 id="2-growpart">2. growpart</h2>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">growpart /dev/sda <span class="m">3</span>
</span></span><span class="line"><span class="cl"><span class="c1"># CHANGED: partition=3 start=4198400 old: size=… end=… new: size=… end=…</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p><code>growpart</code> stretches the partition to the end of the disk, moves the GPT backup header, and tells the kernel about the new table even with the partition mounted (it uses <code>partx --update</code>). It only works on the <strong>last</strong> partition; if a swap partition sits behind the root, remove it first (<code>swapoff</code>, delete it with <code>fdisk</code>, recreate it at the end).</p>
<p>Without <code>growpart</code>: <code>parted /dev/sda resizepart 3 100%</code> does the same with a confirmation prompt.</p>
<h2 id="3a-lvm">3a. LVM</h2>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">pvresize /dev/sda3                                  <span class="c1"># the PV fills the now-larger partition</span>
</span></span><span class="line"><span class="cl">vgs                                                 <span class="c1"># VFree &gt; 0</span>
</span></span><span class="line"><span class="cl">lvextend -r -l +100%FREE /dev/ubuntu-vg/ubuntu-lv   <span class="c1"># all the space</span>
</span></span><span class="line"><span class="cl">lvextend -r -L +20G /dev/ubuntu-vg/ubuntu-lv        <span class="c1"># or only part of it</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p><code>-r</code> calls <code>resize2fs</code> or <code>xfs_growfs</code> depending on what lives in the LV. Without <code>-r</code>, do it yourself: <code>resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv</code> or <code>xfs_growfs /</code>.</p>
<h2 id="3b-without-lvm">3b. Without LVM</h2>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">resize2fs /dev/sda3                 <span class="c1"># ext4: online</span>
</span></span><span class="line"><span class="cl">xfs_growfs /                        <span class="c1"># xfs: online, on the mount point</span>
</span></span><span class="line"><span class="cl">btrfs filesystem resize max /       <span class="c1"># btrfs</span>
</span></span></code></pre></td></tr></table>
</div>
</div><h2 id="raspberry-pi-and-sd-cards">Raspberry Pi and SD cards</h2>
<p>Same script with other names (Fedora ARM image with LVM):</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">growpart /dev/mmcblk0 <span class="m">3</span>
</span></span><span class="line"><span class="cl">pvresize /dev/mmcblk0p3
</span></span><span class="line"><span class="cl">lvextend -l +100%FREE /dev/fedora/root
</span></span><span class="line"><span class="cl">xfs_growfs -d /
</span></span></code></pre></td></tr></table>
</div>
</div><h2 id="traps">Traps</h2>
<ul>
<li><strong><code>growpart: NOCHANGE</code></strong>: the kernel has not seen the new size yet. Back to step 1.</li>
<li><strong><code>growpart</code> fails in a non-English locale</strong> (it parses <code>sfdisk</code> output): <code>LC_ALL=C growpart /dev/sda 3</code>.</li>
<li><strong><code>GPT PMBR size mismatch</code></strong> in <code>fdisk -l</code> after growing the disk: the GPT backup header stayed where the old disk ended. <code>growpart</code> moves it; if you did it by hand, <code>sgdisk -e /dev/sda</code>.</li>
<li><strong>The partition is not the last one.</strong> Swap or <code>/home</code> behind the root: either move those, or add a new disk and join it to the VG (<code>pvcreate /dev/sdb &amp;&amp; vgextend ubuntu-vg /dev/sdb</code>), which in LVM is faster than reordering partitions.</li>
<li><strong>Shrinking is another story</strong>: ext4 only unmounted; XFS never. Think about it before handing out 2 TB &ldquo;just in case&rdquo;.</li>
<li><strong>Windows</strong> grows from <em>Disk Management → Extend Volume</em>; none of this applies.</li>
</ul>
<h2 id="see-also">See also</h2>
<ul>
<li><a href="/en/posts/proxmox/cloud-image-templates/">cloud-init templates on Proxmox</a>: the host-side <code>qm resize</code> lives there.</li>
<li><a href="/en/posts/linux/lvm-activate-volume-group-after-power-failure/">LVM: the volume group will not activate</a>, in case step 3 gets weird.</li>
<li><a href="/en/posts/k3s/migrate-data/">Move k3s data to another disk</a>, the alternative when what fills up is one specific service.</li>
</ul>
]]></content:encoded></item><item><title>LVM: the volume group will not activate after a power failure</title><link>https://inet.sh/en/posts/linux/lvm-activate-volume-group-after-power-failure/</link><pubDate>Fri, 25 Sep 2026 00:00:00 +0000</pubDate><guid>https://inet.sh/en/posts/linux/lvm-activate-volume-group-after-power-failure/</guid><description>After an outage the system drops to emergency mode or a VG is missing: how to diagnose with pvs/vgs/lvs, what vgchange -ay does with --activationmode degraded and partial, when to use lvconvert --repair for a thin pool, vgcfgrestore for broken metadata, and the LVM devices file (system.devices) that hides disks whose ID changed.</description><content:encoded><![CDATA[<h2 id="tldr">TL;DR</h2>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">vgscan
</span></span><span class="line"><span class="cl">pvs<span class="p">;</span> vgs<span class="p">;</span> lvs -a -o +devices,lv_health_status     <span class="c1"># is a PV missing? which LV will not activate and why?</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">vgchange -ay                                       <span class="c1"># normal attempt</span>
</span></span><span class="line"><span class="cl">vgchange -ay --activationmode degraded             <span class="c1"># LVM raid1/raid5/raid6 LVs with a missing PV</span>
</span></span><span class="line"><span class="cl">vgchange -ay --activationmode partial              <span class="c1"># any LV with a missing PV: ONLY to copy data, mount ro</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>If the failure is at boot (emergency shell because <code>/</code> or <code>/home</code> does not show up), run the same commands from the initramfs prompt, prefixed with <code>lvm</code> if there are no standalone binaries (<code>lvm vgchange -ay</code>), then <code>exit</code>.</p>
<h2 id="what-to-look-at-first">What to look at first</h2>
<table>
  <thead>
      <tr>
          <th>Command</th>
          <th>What it tells you</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>pvs</code></td>
          <td><code>WARNING: Couldn't find device with uuid …</code> or <code>[unknown]</code>: a PV is gone. Dead disk, controller that did not enumerate, cable, or an ID that changed</td>
      </tr>
      <tr>
          <td><code>lvs -a -o +devices,lv_health_status</code></td>
          <td>Attribute <code>p</code> = <em>partial</em>; <code>lv_health_status</code> says <code>partial</code>, <code>refresh needed</code>, <code>needs check</code>…</td>
      </tr>
      <tr>
          <td><code>dmesg | grep -iE 'sd[a-z]|nvme|error'</code></td>
          <td>Did the disk come back after the outage? Is it throwing read errors?</td>
      </tr>
      <tr>
          <td><code>journalctl -b | grep -i lvm</code></td>
          <td>What autoactivation tried at boot and why it failed</td>
      </tr>
      <tr>
          <td><code>ls /etc/lvm/archive/</code></td>
          <td>Copies of the metadata before every change; you need them if a restore is due</td>
      </tr>
  </tbody>
</table>
<p>The three activation modes (<code>man vgchange</code>): <strong>complete</strong> (the default) only activates LVs with all their PVs present; <strong>degraded</strong> activates LVM RAID LVs missing a leg; <strong>partial</strong> activates any LV even with missing PVs, filling the gaps with errors or zeros, and is only for recovery.</p>
<h2 id="cases">Cases</h2>
<h3 id="1-a-pv-is-missing">1. A PV is missing</h3>
<p>Fix the hardware first: reseat, change ports, check the controller. As soon as <code>pvs</code> sees it, <code>vgchange -ay</code> and done.</p>
<p>If the disk does not come back and the LV was linear across several PVs, whatever lived on that disk is gone. Rescue the rest <strong>read-only</strong>:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">vgchange -ay --activationmode partial
</span></span><span class="line"><span class="cl">mount -o ro /dev/vg01/data /mnt/rescue
</span></span><span class="line"><span class="cl">rsync -a /mnt/rescue/ /somewhere/else/
</span></span></code></pre></td></tr></table>
</div>
</div><p>And only after copying, clean up the VG: <code>vgreduce --removemissing --force vg01</code>.</p>
<h3 id="2-lvm-raid-lvs-raid1-raid5-raid6">2. LVM RAID LVs (raid1, raid5, raid6)</h3>
<p>With a missing leg they come up in degraded mode:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">vgchange -ay --activationmode degraded
</span></span></code></pre></td></tr></table>
</div>
</div><p>Then replace the PV: <code>vgextend vg01 /dev/sdX</code> with the new disk and <code>lvconvert --repair vg01/data</code>. If the LV will not activate even so (<code>reload ioctl … failed</code>, <code>_rimage_</code> sub-LVs active but not the LV), you are in the scenario where LVM RAID tooling falls short; restoring from backup is the honest way out. For parity RAID, <a href="/en/posts/linux/mdadm-add-disk-grow-raid5/">mdadm</a> under LVM gives better recovery tools.</p>
<h3 id="3-thin-pool">3. Thin pool</h3>
<p>Thin pools suffer the most from an outage: at boot, <code>thin_check</code> finds the metadata inconsistent and LVM refuses:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">Check of pool vg01/pool0 failed (status:1). Manual repair required!
</span></span></code></pre></td></tr></table>
</div>
</div><p>The fix is what the message says, with the pool <strong>inactive</strong>:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">lvconvert --repair vg01/pool0
</span></span><span class="line"><span class="cl">vgchange -ay vg01
</span></span></code></pre></td></tr></table>
</div>
</div><p><code>--repair</code> rebuilds the metadata into a new LV and keeps the old one as <code>pool0_meta0</code>; once you confirm the thin volumes mount fine, <code>lvremove vg01/pool0_meta0</code>. A thin pool with a missing PV will not activate even in <code>degraded</code> mode; only <code>partial</code> remains, to copy.</p>
<h3 id="4-broken-metadata-pvs-present-vg-incomplete-or-unknown">4. Broken metadata (PVs present, VG &ldquo;incomplete&rdquo; or &ldquo;unknown&rdquo;)</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">vgcfgrestore --list vg01                                <span class="c1"># files in /etc/lvm/archive with date and reason</span>
</span></span><span class="line"><span class="cl">vgcfgrestore -f /etc/lvm/archive/vg01_00042-1234567890.vg vg01
</span></span><span class="line"><span class="cl">vgchange -ay vg01
</span></span></code></pre></td></tr></table>
</div>
</div><p>Metadata only: if what is missing is a disk, restoring the configuration does not bring it back.</p>
<h3 id="5-the-disk-is-there-but-lvm-ignores-it">5. The disk is there, but LVM ignores it</h3>
<p>On RHEL 9, Fedora, and derivatives LVM only looks at the devices listed in <code>/etc/lvm/devices/system.devices</code>. If the outage made a disk come back under another identifier (controller change, different WWID, cloned disk), LVM does not consider it even though <code>lsblk</code> shows it:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">lvmdevices                          <span class="c1"># current list</span>
</span></span><span class="line"><span class="cl">lvmdevices --adddev /dev/sdc        <span class="c1"># add the device</span>
</span></span><span class="line"><span class="cl">vgimportdevices -a                  <span class="c1"># or import every VG it finds</span>
</span></span><span class="line"><span class="cl">vgchange -ay
</span></span></code></pre></td></tr></table>
</div>
</div><h2 id="after-activating">After activating</h2>
<p>An outage breaks filesystems more often than LVM. Before mounting read-write:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">fsck -n /dev/vg01/data        <span class="c1"># ext4: look only</span>
</span></span><span class="line"><span class="cl">xfs_repair -n /dev/vg01/data  <span class="c1"># xfs: look only</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>And if the result looks scary, mount <code>ro</code>, copy, and repair afterwards.</p>
<h2 id="traps">Traps</h2>
<ul>
<li><strong><code>partial</code> fixes nothing</strong>: what is missing reads as zeros or errors and any write there is lost. Mount read-only and copy.</li>
<li><strong>Do not <code>vgreduce --removemissing</code> before copying.</strong> It is the last step, not the first.</li>
<li><strong><code>/etc/lvm/backup</code> and <code>/etc/lvm/archive</code> are gold</strong> and live on the same disk that can fail. Copy them off the machine now and then (<code>vgcfgbackup -f /external/path/%s.vg</code>).</li>
<li><strong>In VMs the &ldquo;power failure&rdquo; is a forced stop</strong>; same recipe. And if what does not boot is GRUB itself with root on LVM, that is <a href="/en/posts/proxmox/grub-rescue-disk-lvmid-not-found/">another problem</a>.</li>
</ul>
<p>References: <code>man 8 vgchange</code>, <code>man 7 lvmthin</code>, and <code>man 8 lvmdevices</code>.</p>
]]></content:encoded></item><item><title>Proxmox: error: disk 'lvmid/…' not found at grub rescue</title><link>https://inet.sh/en/posts/proxmox/grub-rescue-disk-lvmid-not-found/</link><pubDate>Fri, 25 Sep 2026 00:00:00 +0000</pubDate><guid>https://inet.sh/en/posts/proxmox/grub-rescue-disk-lvmid-not-found/</guid><description>A Proxmox VE node that boots into &amp;#39;error: disk lvmid/... not found, grub rescue&amp;gt;&amp;#39; with root on LVM: it is a GRUB bug reading LVM metadata when the ring buffer wraps around. Workaround from the ISO (any LVM change) and permanent fix by reinstalling the GRUB that carries the fix.</description><content:encoded><![CDATA[<h2 id="tldr">TL;DR</h2>
<p>Boot the <strong>Proxmox ISO → Advanced Options → Install Proxmox VE (Debug mode)</strong>; at the first shell press <code>Ctrl+D</code> to reach the second one, which already has LVM:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">vgscan
</span></span><span class="line"><span class="cl">vgchange -ay
</span></span><span class="line"><span class="cl">lvcreate -L 4M pve -n grubtemp   <span class="c1"># any change to the LVM metadata will do</span>
</span></span><span class="line"><span class="cl">reboot
</span></span></code></pre></td></tr></table>
</div>
</div><p>With the node back up, clean up and make the fix permanent:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">lvremove pve/grubtemp
</span></span><span class="line"><span class="cl"><span class="o">[</span> -d /sys/firmware/efi <span class="o">]</span> <span class="o">&amp;&amp;</span> apt install grub-efi-amd64     <span class="c1"># UEFI</span>
</span></span><span class="line"><span class="cl"><span class="c1"># legacy BIOS: grub-install /dev/sdX &amp;&amp; update-grub        # the disk, not the partition</span>
</span></span></code></pre></td></tr></table>
</div>
</div><h2 id="the-error">The error</h2>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">error: disk &#39;lvmid/Xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxxx/Yyyyyy-yyyy-yyyy-yyyy-yyyy-yyyy-yyyyyy&#39; not found.
</span></span><span class="line"><span class="cl">Entering rescue mode...
</span></span><span class="line"><span class="cl">grub rescue&gt;
</span></span></code></pre></td></tr></table>
</div>
</div><p>The disk is fine, the <code>pve</code> VG is fine, and the data is fine. Sometimes the same bug warns you earlier, during an <code>apt full-upgrade</code>:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">/usr/sbin/grub-probe: error: disk `lvmid/...&#39; not found.
</span></span></code></pre></td></tr></table>
</div>
</div><p>If you see that in <code>update-grub</code>, apply the fix <strong>before</strong> rebooting.</p>
<h2 id="why-it-happens">Why it happens</h2>
<p>LVM stores its on-disk metadata in a <strong>ring buffer</strong>. Every change (creating, deleting, or resizing an LV) writes a new copy further along the buffer, and sooner or later the text wraps around the end. The GRUB 2.06 in Debian 11 (PVE 7, <code>2.06-3</code>) cannot read that wrap: it does not find the VG, does not find the <code>pve/root</code> LV, and drops to <code>grub rescue</code>.</p>
<p>That is why &ldquo;fixing&rdquo; it is as odd as making any LVM change: the metadata gets rewritten at another position, usually without a wrap, and GRUB reads it again. And that is why it <strong>comes back</strong> weeks or months later, when the buffer wraps again, if the GRUB installed on the disk is still the old one.</p>
<p>In the lab the change that got us out was <code>lvextend -L +1G /dev/pve/root</code>. It works just the same, but undoing it with <code>lvreduce</code> on a mounted root is playing with fire; if you did it that way, better keep the 1G (<code>resize2fs /dev/pve/root</code>) or use the throwaway LV from the TL;DR.</p>
<h2 id="full-procedure">Full procedure</h2>
<ol>
<li>
<p><strong>Get into the system.</strong> Two ways from the Proxmox ISO:</p>
<ul>
<li><strong>Rescue Boot</strong> (Advanced Options): the ISO finds the installation and boots its kernel, bypassing the broken GRUB. If it works you are already inside the real system and can jump to step 3.</li>
<li><strong>Debug mode</strong>: rescue shell. <code>Ctrl+D</code> at the first prompt; the second one has the LVM modules loaded.</li>
</ul>
</li>
<li>
<p><strong>Trigger a metadata change</strong> (only if you came in through Debug mode):</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">vgscan
</span></span><span class="line"><span class="cl">vgchange -ay
</span></span><span class="line"><span class="cl">lvcreate -L 4M pve -n grubtemp
</span></span><span class="line"><span class="cl">reboot
</span></span></code></pre></td></tr></table>
</div>
</div></li>
<li>
<p><strong>Back in the normal system</strong>, remove the temporary LV and check whether the metadata still wraps:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">lvremove pve/grubtemp
</span></span><span class="line"><span class="cl">vgscan -vvv 2&gt;<span class="p">&amp;</span><span class="m">1</span> <span class="p">|</span> grep <span class="s1">&#39;Reading metadata&#39;</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>Output ending in <code>(+0)</code> means no wrap; any other value means the problem will repeat until you reinstall GRUB.</p>
</li>
<li>
<p><strong>Reinstall the GRUB that has the fix.</strong> The PVE 8 and 9 package (<code>2.06-13</code> or newer) already carries it, but the binary sitting in the ESP or the MBR is only rewritten when the package gets (re)installed:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span><span class="lnt">8
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl"><span class="c1"># UEFI: nodes upgraded from PVE 7 often have grub-pc instead of grub-efi-amd64</span>
</span></span><span class="line"><span class="cl">dpkg -l <span class="p">|</span> grep -E <span class="s1">&#39;^ii +grub-&#39;</span>
</span></span><span class="line"><span class="cl">apt install grub-efi-amd64
</span></span><span class="line"><span class="cl">efibootmgr -v            <span class="c1"># confirm the &#34;proxmox&#34; entry</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># legacy BIOS</span>
</span></span><span class="line"><span class="cl">grub-install /dev/sdX
</span></span><span class="line"><span class="cl">update-grub
</span></span></code></pre></td></tr></table>
</div>
</div><p>On PVE 7 the real fix is upgrading to PVE 8; the workaround only buys time.</p>
</li>
</ol>
<h2 id="traps">Traps</h2>
<ul>
<li><strong><code>grub rescue&gt;</code> will not get you out of this.</strong> <code>ls (lvm/pve-root)</code> shows nothing because the <code>lvm</code> module is exactly what cannot read the metadata. Do not waste time there.</li>
<li><strong>Root on ZFS does not go through here.</strong> Nodes with <code>rpool</code> boot via <code>proxmox-boot-tool</code>; that is another path with other errors.</li>
<li><strong>Point at the right devices</strong> if you run <code>grub-install</code> by hand: the disk (<code>/dev/sda</code>), not <code>/dev/sda1</code>; the ESP mounted on <code>/boot/efi</code> for UEFI.</li>
<li><strong>In a cluster</strong>, once one node is fixed check the others with <code>vgscan -vvv | grep 'Reading metadata'</code>; same installation, same buffer.</li>
</ul>
<p>References: <a href="https://pve.proxmox.com/wiki/Recover_From_Grub_Failure">Recover From Grub Failure</a> on the Proxmox wiki and the <a href="https://forum.proxmox.com/threads/error-disk-lvmid-not-found-grub-rescue.123512/">forum thread</a>.</p>
]]></content:encoded></item></channel></rss>