我与 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
我尝试了问题命令的多种变体:
- 使用不同的
--location
URL,包括https://cloud-images.ubuntu.com/bionic/和http://ftp.at.debian.org/debian/dists/stable/main/installer-amd64/ - 我直接从 Ubuntu 下载了一个安装 ISO,并尝试使用
--location
- 我尝试使用完整的图像(具体来说:https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img)
所有建议均由一位朋友提出,他以前遇到过同样的错误并且不记得如何解决。
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