自动安装 Ubuntu Server 22.04:块探测未发现任何足够大的磁盘来支持引导式存储配置

自动安装 Ubuntu Server 22.04:块探测未发现任何足够大的磁盘来支持引导式存储配置

语境

运行以下 bash 脚本使用 virt-install 在 Qemu 上自动安装 Ubuntu 服务器 22.04 后,我收到错误:

块探测没有发现任何足够大的磁盘来支持引导存储配置。

此外,在我看来,virt-install 无法识别该user-data文件seed.iso,因为终端提示我想要在服务器上使用哪种语言: 在此处输入图片描述 即使(我相信)这是用locale: en_US文件中的行指定的user-data

安装脚本

文件:install.sh包含:

#!/bin/bash

# USERNAME="$(echo $whoami)"
USERNAME="$(whoami)"
# read -p "USERNAME=$USERNAME"
CURRENT_DIR="$PWD"
echo "CURRENT_DIR=$CURRENT_DIR"

version=22
VM_NAME="ubu$version"

DISK_SIZE=30

# Install qemu.
sudo apt-get install qemu-kvm >>/dev/null 2>&1
# Install the virtual installer that installs Ubuntu on Qemu.
#sudo apt-get install virt-install
sudo apt-get install virt-manager >>/dev/null 2>&1
# Allow copy paste between qemu Ubuntu and your own device
sudo apt-get install spice-vdagent >>/dev/null 2>&1
# Allow a bridge between qemu and your own device to grant Ubuntu internet.
sudo apt-get install libvirt-daemon-system >>/dev/null 2>&1
sudo apt-get install libvirt-clients >>/dev/null 2>&1
sudo apt-get install genisoimage >>/dev/null 2>&1
#sudo apt-get install python-libvirt

# Create working directory
cd /home/$USERNAME/
mkdir -p /home/$USERNAME/qemus
cd /home/$USERNAME/qemus

# Create iso of autoinstall.yaml
SEED_PATH=/home/$USERNAME/qemus/seed.iso
sudo rm "$SEED_PATH"
sudo rm "$CURRENT_DIR/seed$version/meta-data"
touch "$CURRENT_DIR/seed$version/meta-data"
genisoimage -o "$SEED_PATH" -r -J "$CURRENT_DIR/seed$version/"
sudo rm "$CURRENT_DIR/seed$version/meta-data"

## Define variables
MEM_SIZE=3072            # Memory setting in MiB
VCPUS=1                  # CPU Cores count
OS_VARIANT="ubuntu22.04" # Select from the output of "osinfo-query os"
# LOCATION="/home/$USERNAME/qemus/ubuntu-23.04-desktop-amd64.iso"
LOCATION="/home/$USERNAME/qemus/ubuntu-22.04.2-live-server-amd64.iso"
OS_TYPE="linux"

# Download the Ubuntu iso.
# wget -O "$LOCATION" https://releases.ubuntu.com/lunar/ubuntu-22.04-desktop-amd64.iso
wget -O "$LOCATION" https://releases.ubuntu.com/22.04.2/ubuntu-22.04.2-live-server-amd64.iso

# DISK_FILE="./${VM_NAME}.qcow2"
DISK_FILE="/home/$USERNAME/qemus/${VM_NAME}.qcow2"
sudo rm "$DISK_FILE"
touch "$DISK_FILE"
chmod 777 "$DISK_FILE"

virt-install \
    --virt-type kvm \
    --name ${VM_NAME} \
    --memory=${MEM_SIZE} \
    --vcpus=${VCPUS} \
    --os-type ${OS_TYPE} \
    --cpu host-passthrough \
    --features smm.state=on \
    --disk path="$DISK_FILE",size=${DISK_SIZE},format=qcow2,sparse=true,bus=scsi,discard=unmap  \
    --controller type=scsi,model=virtio-scsi \
    --network bridge=virbr0 \
    --metadata title='Ubuntu 22.04 (CIS)' \
    --disk path="$SEED_PATH",size=${DISK_SIZE},device=cdrom,bus=sata \
    --location ${LOCATION},kernel=casper/vmlinuz,initrd=casper/initrd \
    --channel spicevmc,target_type=virtio,name=com.redhat.spice.0 \
    --channel unix,target_type=virtio,name=org.qemu.guest_agent.0 \
    --graphics spice,gl.enable=no,listen=none \
    --video qxl \
    --console pty,target_type=virtio \
    --tpm type=emulator,version=2.0,model=tpm-tis \
    --boot loader=/usr/share/OVMF/OVMF_CODE_4M.secboot.fd,loader.readonly=yes,loader.type=pflash,loader.secure=yes,nvram.template=/usr/share/OVMF/OVMF_VARS_4M.ms.fd \
    --extra-args='autoinstall' \
    --noreboot

virsh change-media jammy_cis sdc --eject --force

seed22并且它与包含名为的自动安装文件的文件夹位于同一目录中: user-data

自动安装文件

这是该文件的内容user-data

version: 1
reporting:
    hook:
        type: webhook
        endpoint: http://example.com/endpoint/path
early-commands:
    - ping -c1 198.162.1.1
locale: en_US
keyboard:
    layout: gb
    variant: dvorak
network:
    network:
        version: 2
        ethernets:
            enp0s25:
               dhcp4: yes
            enp3s0: {}
            enp4s0: {}
        bonds:
            bond0:
                dhcp4: yes
                interfaces:
                    - enp3s0
                    - enp4s0
                parameters:
                    mode: active-backup
                    primary: enp3s0
proxy: http://squid.internal:3128/
apt:
    primary:
        - arches: [default]
          uri: http://repo.internal/
    sources:
        my-ppa.list:
            source: "deb http://ppa.launchpad.net/curtin-dev/test-archive/ubuntu jammy main"
            keyid: B59D 5F15 97A5 04B7 E230  6DCA 0620 BBCF 0368 3F77
storage:
    layout:
        name: lvm
identity:
    hostname: hostname
    username: username
    password: $6$jIFnr1YHWk/TYCfD$6nnv2yn6AzQOpOslPTPE0dZlA75OFR4ZiVpEOeDByLFJ/AW0D45FC6.NaLHkrU1vtffFwDIshYgUnUx0hGN051
snaps:
    - name: go
      channel: 1.14/stable
      classic: true
debconf-selections: |
    bind9      bind9/run-resolvconf    boolean false
packages:
    - libreoffice
    - dns-server^
user-data:
    disable_root: false
late-commands:
    - sed -ie 's/GRUB_TIMEOUT=.\*/GRUB_TIMEOUT=30/' /target/etc/default/grub
error-commands:
    - tar c /var/log/installer | nc 192.168.0.1 1000

密码的 md5sum 是密码的 md5sum ubuntu:。

磁盘大小 0

错误Block probing..消息如上所述,我认为发生这种情况是因为安装无法识别任何磁盘(30 gb,如DISK_SIZE=30在:中指定install.sh:): 在此处输入图片描述

问题

我如何确保 Ubuntu 服务器安装识别自动安装yaml和 30 GB 的磁盘大小?

相关内容