Direct booting Linux kernel with qemu-system-x86_64 - kernel bzImage
To directly boot a Linux kernel using qemu-system-x86_64, you need to provide the bzImage kernel file. Here's an example command:
qemu-system-x86_64 -bios /path/to/your/bios.fd -m 512 -smp 2 -cpu host -kernel /path/to/your/bzImage -append 'root=/dev/vda1 console=ttyS0,115200n8' -serial mon:stdio
Explanation of the command:
qemu-system-x86_64: This is the command to start QEMU as an x86_64 system.-bios /path/to/your/bios.fd: This option specifies the path to the BIOS file for the virtual machine.-m 512: This option sets the amount of RAM for the virtual machine (512 MB in this example).-smp 2: This option sets the number of CPU cores for the virtual machine (2 cores in this example).-cpu host: This option uses the host's CPU for emulation.-kernel /path/to/your/bzImage: This option specifies the path to the bzImage kernel file.-append 'root=/dev/vda1 console=ttyS0,115200n8': This option appends parameters to the kernel command line. In this example, it sets the root file system and console output.-serial mon:stdio: This option enables a serial console and redirects its output to the terminal.
Direct booting Windows 10 with PowerShell - Mac
To directly boot Windows 10 using PowerShell on a Mac, you can use the add-serialmon:stdio command. Here's an example:
qemu-system-x86_64 -cdrom /path/to/your/Windows10.iso -m 4096 -smp 4 -cpu host -boot d -device e1000-82545em,netdev=user.vhost-user-server-0 -netdev user,id=user.vhost-user-server-0,hostfwd=tcp::5555-hostfd=ssh -device isa-serial,chardev=charport,id=charport0,bus=pci.0 -chardev socket,path=/tmp/qemu.sock,id=char0 -mon chardev=char0 -serial mon:stdio
powershell -Command "(New-Object -ComObject VirtualBox.Service) | Select-Object -ExpandProperty 'RegisterGuestService' -ArgumentList 'VBoxSVR' | Out-Null; Add-Type -AssemblyName VirtualBox; Add-Type -AssemblyName Microsoft.HyperV.PowerShell; Add-PSSnapin Microsoft.HyperV.PowerShell; Connect-VMNetworkAdapter -VMName 'Windows 10' -SwitchName 'vSwitch'; Start-VM 'Windows 10'"
Explanation of the commands:
qemu-system-x86_64: This is the command to start QEMU as an x86_64 system.-cdrom /path/to/your/Windows10.iso: This option specifies the path to the Windows 10 ISO file.-m 4096: This option sets the amount of RAM for the virtual machine (4 GB in this example).-smp 4: This option sets the number of CPU cores for the virtual machine (4 cores in this example).-cpu host: This option uses the host's CPU for emulation.-boot d: This option tells QEMU to boot from the CD-ROM.-device e1000-82545em,netdev=user.vhost-user-server-0: This option adds an E1000 network adapter and assigns it to the user-defined network.-netdev user,id=user.vhost-user-server-0,hostfwd=tcp::5555-hostfd=ssh: This option creates a user-mode network connection and forwards the TCP port 5555 to the host SSH.-device isa-serial,chardev=charport,id=charport0,bus=pci.0: This option adds an ISA serial port.-chardev socket,path=/tmp/qemu.sock,id=char0: This option creates a Unix domain socket for the serial port.-mon chardev=char0: This option enables a monitor on the serial port.-serial mon:stdio: This option enables a serial console and redirects its output to the terminal.- The second command is a PowerShell script that connects to the virtual machine using the VirtualBox and Hyper-V PowerShell snap-ins and starts the VM.