qemu+kvm,無用的 virt-install --location 錯誤

qemu+kvm,無用的 virt-install --location 錯誤

我與 qemu 和 virt-install 進行了鬥爭,但沒有成功,而且我完全被一條無用的錯誤訊息困住了,這讓我一事無成。

首先,一些必要的系統配置:

基礎金屬作業系統是 Ubuntu Server 20.04 LTS。沒有桌面環境。 VM 作業系統將為 Ubuntu Server 18.04 LTS。沒有桌面環境。

我有一個 60GB LVM,/dragonode打算用作該虛擬機器的主儲存磁碟區:

calyodelphi@dragonweyr:~$ lsblk
NAME                           MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
[loop partitions omitted]
nvme0n1                        259:0    0   477G  0 disk 
├─nvme0n1p1                    259:1    0   512M  0 part /boot/efi
├─nvme0n1p2                    259:2    0     1G  0 part /boot
└─nvme0n1p3                    259:3    0 475.4G  0 part 
  ├─ubuntu--vg-ubuntu--lv      253:0    0    50G  0 lvm  /
  ├─ubuntu--vg-dragonode--lv   253:1    0    60G  0 lvm  /dragonode
  └─ubuntu--vg-dragonhoard--lv 253:2    0 365.4G  0 lvm  /dragonhoard

我已經成功配置了一個帶有 netplan 的網橋作為系統的金屬介面:

calyodelphi@dragonweyr:~$ ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP mode DEFAULT group default qlen 1000
    link/ether f8:75:a4:b5:ca:ba brd ff:ff:ff:ff:ff:ff
3: wlo1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000
    link/ether 94:e6:f7:36:91:d8 brd ff:ff:ff:ff:ff:ff
4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether f8:75:a4:b5:ca:ba brd ff:ff:ff:ff:ff:ff

現在我拼湊出的命令和問題是:

calyodelphi@dragonweyr:~$ virt-install --name dragonode --ram=2048 --disk path=/dragonode/dragonode.qcow2,size=50,format=qcow2 --vcpus 1 --os-type linux --os-variant ubuntu18.04 --graphics none --network bridge:br0 --location 'http://archive.ubuntu.com/ubuntu/dists/bionic/main/binary-amd64/' --extra-args "console=tty0 console=ttyS0,115200n8 ip=192.168.1.144::192.168.1.1:255.255.255.0:dragonode.home:eth0:none"
ERROR    Error validating install location: Could not find an installable distribution at 'http://archive.ubuntu.com/ubuntu/dists/bionic/main/binary-amd64/'

The location must be the root directory of an install tree.
See virt-install man page for various distro examples.

我組裝的大部分命令主要是使用本指南有一點額外的參考這個例子集合(特別是連結部分)和這個有用的 RedHat 文檔,也直接和第一篇文章的作者進行了留言交流。

但是,執行上述命令後,您會看到無用的一般錯誤。

令人沮喪的是,該 URL 出現了直接從線上說明頁virt-install--location參數定義中:

-l, --location OPTIONS
   Distribution tree installation source. virt-install can recognize certain distribution trees and fetches a bootable kernel/initrd pair to
   launch the install.

   --location allows things like --extra-args for kernel arguments, and using --initrd-inject. If you want to use those options with CDROM media,
   you can pass the ISO to --location as well which works for some, but not all, CDROM media.

   The "LOCATION" can take one of the following forms:

   https://host/path
       An HTTP server location containing an installable distribution image.

   ftp://host/path
       An FTP server location containing an installable distribution image.

   ISO Probe the ISO and extract files using 'isoinfo'

   DIRECTORY
       Path to a local directory containing an installable distribution image. Note that the directory will not be accessible by the guest after
       initial boot, so the OS installer will need another way to access the rest of the install media.

   Some distro specific url samples:

   Fedora/Red Hat Based
       https://download.fedoraproject.org/pub/fedora/linux/releases/29/Server/x86_64/os

   Debian
       https://ftp.us.debian.org/debian/dists/stable/main/installer-amd64/

   Ubuntu
       https://us.archive.ubuntu.com/ubuntu/dists/wily/main/installer-amd64/

   Suse
       https://download.opensuse.org/pub/opensuse/distribution/leap/42.3/repo/oss/

   Additionally, --location can take 'kernel' and 'initrd' sub options. These paths relative to the specified location URL/ISO that allow
   selecting specific files for kernel/initrd within the install tree. This can be useful if virt-install/ libosinfo doesn't know where to find
   the kernel in the specified --location.

   For example, if you have an ISO that libosinfo doesn't know about called my-unknown.iso, with a kernel at 'kernel/fookernel' and initrd at
   'kernel/fooinitrd', you can make this work with:

     --location my-unknown.iso,kernel=kernel/fookernel,initrd=kernel/fooinitrd

我嘗試了問題命令的多種變體:

所有建議均來自一位以前遇到過同樣錯誤但不記得如何解決的朋友。

ISO 嘗試導致了最後幾行似乎就像最初的成功一樣:

mount: mounting /root/cdrom/casper/extras/modules.squashfs-generic on /root/lib/modules failed: No such file or directory
mount: mounting /dev on /root/dev failed: No such file or directory
[a few more of these]
run-init: current directory on the same filesystem as the root: error 0
Target filesystem doesn't have requested /sbin/init.
[more run-init errors]
No init found. Try passing init= bootarg.


BusyBox v1.27.2 (Ubuntu 1:1.27.2-2ubuntu3.3) built-in shell (ash)
Enter 'help' for a list of built-in commands.

(initramfs)

我遠遠超出了自己解決此問題的能力,並且迫切需要幫助來運行虛擬機器。

我打算完成的虛擬機器設定:

  • 虛擬機器位於路徑/dragonode/dragonode.qcow2
  • VM作業系統:Ubuntu 18.04 LTS,無圖形
  • 將虛擬機器的虛擬網路介面綁定到br0
  • 配置 IP 位址 192.168.1.144,以便我可以立即 ssh 到它
  • 其餘的在原始命令中應該是不言自明的

答案1

我只使用Ubuntu Serverguide 中有關 virt-install 的部分作為參考。此外,還需要圖形來執行實際安裝,可以透過 VNC 進行。使用 ISO 方法,ISO 已下載並位於目前目錄中,這裡有建議的命令(假設它可以從主機網路 DHCP 取得 IP 位址):

virt-install --name dragonode --ram 2048 \
--disk path=/dragonode/dragonode.img,bus=virtio,size=50 \
-c ubuntu-18.04.6-live-server-amd64.iso \
--network bridge=br0,model=virtio \
--video=vmvga --graphics vnc,listen=0.0.0.0 --noautoconsole -v --vcpus=1

相關內容