lvextend 根分区导致 (initramfs) 警报!/dev/mapper/ubuntu--vg-ubuntu--lv 不存在。降入 shell!

lvextend 根分区导致 (initramfs) 警报!/dev/mapper/ubuntu--vg-ubuntu--lv 不存在。降入 shell!

我正在使用打包器 qemu 构建器构建 Ubuntu 22.04.02 映像。然后我将原始映像 dd 到裸机迷你电脑。在 Ubuntu 映像的第一次启动时,我有一个扩展根分区以填满剩余磁盘空间的过程。

这是扩展之前的 fdisk 输出:

# fdisk -l
GPT PMBR size mismatch (16777215 != 250069679) will be corrected by write.
The backup GPT table is not on the end of the device.
Disk /dev/nvme0n1: 119.24 GiB, 128035676160 bytes, 250069680 sectors
Disk model: Vaseky V900/128GB                       
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F13F5D26-3087-4728-9C50-8D062F54B00B

Device           Start      End  Sectors  Size Type
/dev/nvme0n1p1    2048  1103871  1101824  538M EFI System
/dev/nvme0n1p2 1103872  4773887  3670016  1.8G Linux filesystem
/dev/nvme0n1p3 4773888 16775167 12001280  5.7G Linux filesystem

在 lvextend 之后我看到了这个:

Disk /dev/nvme0n1: 119.24 GiB, 128035676160 bytes, 250069680 sectors
Disk model: Vaseky V900/128GB                       
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F13F5D26-3087-4728-9C50-8D062F54B00B

Device           Start       End   Sectors  Size Type
/dev/nvme0n1p1    2048   1103871   1101824  538M EFI System
/dev/nvme0n1p2 1103872   4773887   3670016  1.8G Linux filesystem
/dev/nvme0n1p3 4773888 250069646 245295759  117G Linux filesystem

扩展似乎工作正常:

# df -h /
Filesystem                         Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-ubuntu--lv  116G  5.3G  106G   5% /

我必须将同样的过程应用到 6-7 种不同的硬件配置中,并且它们都可以正常工作,并且在重新启动盒子时也没有出现任何问题。

这是我正在使用的 lvextend 程序:

    lvpath=$(lvdisplay --noheadings -C  -o "lv_path" | sed 's/^ *//g')
    growpart -v -u auto /dev/nvme0n1 3
    pvresize /dev/nvme0n1p3
    lvextend -l +100%FREE $lvpath
    resize2fs $lvpath

现在由于某种原因,在特定的硬件模型上,我看到 2 个盒子(相同构建)在 lvextend 过程之后重新启动后下降到 initramfs:

Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... [    7.265019] Btrfs loaded, crc32c=crc32c-intel, zoned=yes, fsverity=yes
Scanning for Btrfs filesystems
done.
Begin: Waiting for root file system ... Begin: Running /scripts/local-block ... mdadm: No arrays found in config file or automatically
done.
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: error opening /dev/md?*: No such file or directory
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
mdadm: No arrays found in config file or automatically
done.
Gave up waiting for root file system device.  Common problems:
 - Boot args (cat /proc/cmdline)
   - Check rootdelay= (did the system wait long enough?)
 - Missing modules (cat /proc/modules; ls /dev)
ALERT!  /dev/mapper/ubuntu--vg-ubuntu--lv does not exist.  Dropping to a shell!


BusyBox v1.30.1 (Ubuntu 1:1.30.1-7ubuntu3) built-in shell (ash)
Enter 'help' for a list of built-in commands.

(initramfs) 

我不知道这是怎么回事。有什么想法吗?这个问题只影响了同一制造商制造的 2 台机器(minipc),在我尝试过的许多其他物理构造中,无论是全 PC 类型定制构造、HP DL365 G6 还是其他工业 PC 等,我肯定已经在 6 或 7 种其他外形尺寸上执行了此过程,完全没有问题。

这是我正在使用的打包程序构建配置:

variable "version" {}

source "qemu" "ubuntu" {
  boot_command = [
        "<esc><esc><esc><esc>e<wait>",
        "<del><del><del><del><del><del><del><del>",
        "<del><del><del><del><del><del><del><del>",
        "<del><del><del><del><del><del><del><del>",
        "<del><del><del><del><del><del><del><del>",
        "<del><del><del><del><del><del><del><del>",
        "<del><del><del><del><del><del><del><del>",
        "<del><del><del><del><del><del><del><del>",
        "<del><del><del><del><del><del><del><del>",
        "<del><del><del><del><del><del><del><del>",
        "<del><del><del><del><del><del><del><del>",
        "<del><del><del><del><del><del><del><del>",
        "<del><del><del><del><del><del><del><del>",
        "<del><del><del><del><del><del><del><del>",
        "<del><del><del><del><del><del><del><del><del>",
        "linux /casper/vmlinuz --- autoinstall ds=\"nocloud-net;seedfrom=http://{{.HTTPIP}}:{{.HTTPPort}}/\"<enter><wait>",
        "initrd /casper/initrd<enter><wait>",
        "boot<enter>",
        "<enter><f10><wait>"
  ]
  boot_wait        = "3s"
  accelerator      = "kvm"
  cpus             = "4"
  disk_image       = false
  disk_size        = "16G"
  memory           = 8192
  disk_interface   = "virtio"
  format           = "raw"
  headless         = "true"
  http_directory   = "http"
  iso_url          = "/images/ubuntu-22.04.2-live-server-amd64.iso"
  iso_checksum     = "sha256:5e38b55d57d94ff029719342357325ed3bda38fa80054f9330dc789cd2d43931"
  net_device       = "e1000"
  output_directory = "artifacts"
  vm_name          = "ubuntu-22-base-image-efi.raw"
  qemu_binary      = "kvm"
  shutdown_command = "shutdown -h now"
  ssh_password     = "..."
  ssh_username     = "root"
  ssh_wait_timeout = "60m"
  vnc_bind_address = "0.0.0.0"
  vnc_port_min     = 5960
  vnc_port_max     = 5960
  machine_type     = "q35"
  qemuargs         = [
    [ "-cdrom", "/images/ubuntu-22.04.2-live-server-amd64.iso"],
    [ "-vga",    "virtio" ],
    [ "-serial", "mon:stdio"],
    [ "-device", "virtio-scsi-pci" ],
    [ "-device", "scsi-hd,drive=drive0,bootindex=0" ],
    [ "-device", "scsi-cd,drive=cdrom0,bootindex=1" ],
    [ "-drive",  "if=none,file=artifacts/ubuntu-22-base-image-efi.raw,id=drive0,cache=writeback,discard=ignore,format=raw" ],
    [ "-drive",  "if=none,file=/images/ubuntu-22.04.2-live-server-amd64.iso,id=cdrom0,media=cdrom" ],
    [ "-drive",  "if=pflash,format=raw,readonly=on,file=/usr/share/ovmf/OVMF.fd" ],
  ]
}

build {
  sources = ["source.qemu.ubuntu"]

  provisioner "file" {
    source          = "./files/"
    destination     = "/"
  }

  provisioner "shell" {
    inline = [
      "/var/lib/installer/setup.sh"
    ]
  }

}

更新:

我没有扩大现有分区,而是尝试创建另一个分区,为其创建 PV,并将 PV 添加到现有 VG。结果相同。仍然下降到 initramfs:

# fdisk -l
Disk /dev/nvme0n1: 119.24 GiB, 128035676160 bytes, 250069680 sectors
Disk model: Vaseky V900/128GB                       
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F13F5D26-3087-4728-9C50-8D062F54B00B

Device            Start       End   Sectors   Size Type
/dev/nvme0n1p1     2048   1103871   1101824   538M EFI System
/dev/nvme0n1p2  1103872   4773887   3670016   1.8G Linux filesystem
/dev/nvme0n1p3  4773888  16775167  12001280   5.7G Linux filesystem
/dev/nvme0n1p4 16775168 250069646 233294479 111.2G Linux filesystem


Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 116.96 GiB, 125585850368 bytes, 245284864 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

更新2:解决方法

我找到了一个解决方法!!!如果我​​将 +99%FREE 延长几次,直到不再延长,那么问题就解决了。出于某种原因,问题出在 +100%FREE。它是否弄乱了可用范围计算还是其他什么?

# lvextend -rl +99%FREE $lvpath
  Size of logical volume ubuntu-vg/ubuntu-lv unchanged from 116.96 GiB (29943 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.
resize2fs 1.46.5 (30-Dec-2021)
The filesystem is already 30661632 (4k) blocks long.  Nothing to do!

相关内容