| 1 | .. _direct_005flinux_005fboot: |
| 2 | |
| 3 | Direct Linux Boot |
| 4 | ----------------- |
| 5 | |
| 6 | This section explains how to launch a Linux kernel inside QEMU without |
| 7 | having to make a full bootable image. It is very useful for fast Linux |
| 8 | kernel testing. |
| 9 | |
| 10 | The syntax is: |
| 11 | |
| 12 | .. parsed-literal:: |
| 13 | |
| 14 | |qemu_system| -kernel bzImage -drive file=rootdisk.img,format=raw -append "root=/dev/sda" |
| 15 | |
| 16 | Use ``-kernel`` to provide the Linux kernel image and ``-append`` to |
| 17 | give the kernel command line arguments. The ``-initrd`` option can be |
| 18 | used to provide an INITRD image. |
| 19 | |
| 20 | The ``-shim`` option specifies the ``shim.efi`` binary. This is needed |
| 21 | when you are booting UEFI firmware and using the ``-kernel`` option to |
| 22 | tell UEFI to boot a specific kernel image, and the UEFI firmware you |
| 23 | are booting has UEFI secure boot enabled. |
| 24 | |
| 25 | When this option is specified, the guest UEFI firmware will first |
| 26 | load, verify and run the shim binary, which is typically signed by |
| 27 | Microsoft so the firmware accepts it. The shim binary in turn will |
| 28 | load and verify the Linux kernel. The kernel is typically signed by |
| 29 | the distro and the certificates needed to verify them are compiled |
| 30 | into the shim binary, so shim and kernel must come from the same Linux |
| 31 | distribution. |
| 32 | |
| 33 | Usually you can find shim.efi as ``EFI/BOOT/BOOT{X64,AA64}.EFI`` on |
| 34 | distro install media. You might find a second shim copy in the |
| 35 | ``EFI/$distro/`` directory. |
| 36 | |
| 37 | If you do not need graphical output, you can disable it and redirect the |
| 38 | virtual serial port and the QEMU monitor to the console with the |
| 39 | ``-nographic`` option. The typical command line is: |
| 40 | |
| 41 | .. parsed-literal:: |
| 42 | |
| 43 | |qemu_system| -kernel bzImage -drive file=rootdisk.img,format=raw \ |
| 44 | -append "root=/dev/sda console=ttyS0" -nographic |
| 45 | |
| 46 | Use :kbd:`Ctrl+a c` to switch between the serial console and the monitor (see |
| 47 | :ref:`GUI_keys`). |