17

I seem to recall being able to start qemu with only the terminal emulator output, with the graphic window disabled. And here I don't mean with the ncurses interface, that one is nice, but I want the output to flow directly into my terminal, to make cut and paste easier.

I have tried:

qemu -nographic binary.img # simply no display
qemu -curses binary.img # nice text output, but not directly flowing in the terminal
qemu -noframe -curses binary.img # same as above
qemu -nographic -curses binary.img

I guess an acceptable workaround would be for me to be able to resize the curses console to fit the terminal I am using. Right now it's annoying because it doesn't fit the terminal size...

qemu -curses  binary.img



           SeaBIOS (version 1.7.0-20120603_194846-gandalf)



           iPXE (http://ipxe.org) 00:03.0 C900 PCI2.10 PnP PMM+07FC86A0+07F886A0 C900


           Booting from Hard Disk...
           [...]

Notice how the display is indented 12 spaces? Annoying. :)

17

Old question, but it might still interest people.

Short anwser :

qemu -nographic -serial mon:stdio -append 'console=ttyS0' binary.img

ttyS0 valid on most PC. it would be something different on ARM system.

Then the serial port and the QEMU are multiplexed on your output. You can switch between them with ctrl-A + C + ENTER.

Long answer: check this blog, it's awesome.

  • 1
    Seemed to work without serial for me. – Ciro Santilli 新疆改造中心996ICU六四事件 May 21 '15 at 20:11
  • yes it seems so on latest qemu it's still interesting to learn you can also to multiplex serial + qemu console on stdio – Fred Sep 15 '15 at 9:23
  • 1
    Unfortunately this doesn't redirect any BIOS output, including int 0x10 output used by real-mode code; you only start getting output once the Linux kernel boots up enough to open the serial port. – David Given Nov 25 '16 at 19:20
  • @DavidGiven I suppose that's a matter of what the BIOS code (which is SeaBIOS, not qemu proper) actually does with the 0x10 "output". – DepressedDaniel Mar 22 '17 at 4:44
  • You can also add console=ttyS0 to GRUB_CMDLINE_LINUX_DEFAULT in /etc/grub (make sure to call update-grub after) for it to take place automatically. – Steve Mar 29 '18 at 4:51
3

Install SGABIOS -- ISTR that recent Qemu versions use it automatically when run with -nographic.

  • oddly enough, that doesn't seem to be packaged in Debian, so I doubt this was what I was using... – anarcat Mar 7 '13 at 3:18
1

You can update GRUB to pass the required options to the kernel. I'm using Ubuntu 18.04, and I did the following:

Update grub in the guest OS:

  • sudoedit /etc/default/grub
  • Change GRUB_CMDLINE_LINUX="" to GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,9600n8"
  • run sudo update-grub

Reboot guest OS using the following:

qemu-system-x86_64 \
  -drive file=ubuntu-18.04-live-server-amd64.img.qcow2,format=qcow2 \
  -nographic \
  -m 4G \
;

I recommend adding -nic user,hostfwd=tcp:127.0.0.1:2222-:22 or similar as an option as well, this will enable ssh connectivity via ssh -p 2222 localhost which gives a slightly nicer interface than the console.

The console options are copied from tldp's remote serial HOWTO

  • the question wasn't really about how to configure grub, but more qemu. but i believe, as the first answer says, that -nographic is correct. thanks for your contirbution! :) – anarcat Nov 30 '18 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.