如何在没有 GUI 的情况下在 QEMU -nographic 上启动和安装 Ubuntu 服务器映像?

如何在没有 GUI 的情况下在 QEMU -nographic 上启动和安装 Ubuntu 服务器映像?

如何在 QEMU 上运行 Ubuntu 16.04 桌面?我已经详细描述了如何在 QEMU 上启动和安装桌面 Ubuntu 映像。

现在我想对服务器映像进行类似的设置,以尽量使事情变得更加简单:

wget http://releases.ubuntu.com/18.04/ubuntu-18.04.1.0-live-server-amd64.iso

我之前已经安装了带有 GUI 的服务器映像,并且该设置似乎是基于文本的,所以我认为它可能会起作用。

但如果我再添加通常

-nographic -serial mon:stdio

例如:

qemu-system-x86_64 -cdrom ubuntu-18.04.1.0-live-server-amd64.iso \
  -drive file=ubuntu-18.04.1.0-live-server-amd64.img.qcow2,format=qcow2 \
  -enable-kvm   -m 2G   -smp 2   -vga virtio -nographic -serial mon:stdio

我只是从来没有在终端序列上得到任何东西。

我还尝试装载该图像来查看里面有什么:

mkdir mydir
sudo mount ubuntu-18.04.1.0-live-server-amd64.iso mydir

看看里面有什么,然后:

cat mydir/boot/grub/grub.cfg

表示命令行上没有console=ttyS0选项,这也许可以解释为什么终端是空的。

但是,如果不先进入 GUI 会话,我就无法编辑 ISO 文件,因为它是以只读方式安装的。

我之前已经使用过云镜像,它非常棒:网上有没有预建的 QEMU Ubuntu 映像(32 位)?但这次我不能使用它,因为我需要 GRUB 来做某事(编辑:没关系,云图像确实有 GRUB,只是默认情况下是隐藏的,请参阅:如何在启动时使用串行控制台进入 GRUB 菜单?

有关的:如何在启动时使用串行控制台进入 GRUB 菜单?如该线程所示,在使用 GUI 更改 GRUB 配置后,我设法让 GRUB 显示在终端上。

在 Ubuntu 16.04 主机上测试。

答案1

您可以为 qemu 提供此选项:

-display curses

   Display video output via curses. For graphics device models which support a text mode, QEMU can display this output using a curses/ncurses interface.Nothing is displayed when the graphics device is in graphical mode or if the graphics device does not support a text mode. Generally only the VGA device models support text mode.

来源:https://www.qemu.org/docs/master/system/invocation.html?highlight=curses

但我认为这不能解决问题,或者不能解决您或其他人的问题。

相关内容