Created
November 11, 2019 23:56
-
-
Save CMCDragonkai/cb76886dea682884dbafc1d76aa658b3 to your computer and use it in GitHub Desktop.
QEMU-KVM boot a new x86-64 Virtual Machine from kernel and initrd #qemu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# assume you have bzImage, initrd, cmdline, share, bootdisk, maindisk | |
# the below will boot a QEMU VM with 2 disks attached (as raw), with host port 55555 mapped to 22 | |
# and also pass the share directory into the VM | |
qemu-system-x86_64 \ | |
-kernel ./bzImage \ | |
-initrd ./initrd \ | |
-smp $(nproc) \ | |
-m 8G \ | |
-append "$(cat ./cmdline)" \ | |
-vga std \ | |
-accel kvm \ | |
-drive file=./bootdisk,format=raw \ | |
-drive file=./maindisk,format=raw \ | |
-device virtio-net,netdev=vmnic \ | |
-netdev user,id=vmnic,hostfwd=tcp:127.0.0.1:55555-:22 \ | |
-virtfs local,path=./share,mount_tag=share,security_model=passthrough | |
# you will also need to run `mount -t 9p -o trans=virtio share /mnt/share` inside the guest OS to mount the shared directory | |
# note that the above is a paravirtualized system, it requires support from the guest OS to have virtio drivers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment