Ubuntu – How to boot and install the Ubuntu server image on QEMU -nographic without the GUI


At How to run Ubuntu 16.04 Desktop on QEMU? I have described in detail how to boot and install the desktop Ubuntu image on QEMU.

Now I wanted to do a similar setup for the server image to try keep things more minimal:

wget http://releases.ubuntu.com/18.04/ubuntu-

I have installed the server image with the GUI previously, and the setup seems to be text based, so I thought it might work.

But then, if I just add the usual:

-nographic -serial mon:stdio

as in:

qemu-system-x86_64 -cdrom ubuntu- \
  -drive file=ubuntu-,format=qcow2 \
  -enable-kvm   -m 2G   -smp 2   -vga virtio -nographic -serial mon:stdio

I just never get anything on the terminal serial.

I also tried to mount the image to see what was inside:

mkdir mydir
sudo mount ubuntu- mydir

to see what was inside, and:

cat mydir/boot/grub/grub.cfg

indicates that there is no console=ttyS0 option on the command line, which might explain why the terminal is empty.

I can't edit the ISO file however without first going into a GUI session, as it is mounted readonly.

I have already used the Cloud image previously, and it is great: Is there any prebuilt QEMU Ubuntu image(32bit) online? but I can't use it this time because I need GRUB for something (edit: nevermind, the cloud image does have GRUB, just it is hidden by default, see: How to get to the GRUB menu at boot-time using serial console? )

Related: How to get to the GRUB menu at boot-time using serial console? I managed to get GRUB to show on the terminal after changing the GRUB configuration with the GUI as shown in that thread.

Tested on an Ubuntu 16.04 host.

Best Answer

Related Question