QEMU简单使用的笔记

安装

1
apt update && apt install qemu

启动

支持的架构真的多

1
2
3
4
5
6
7
8
9
10
11
12
13
qemu-aarch64              qemu-mips64               qemu-sh4eb                qemu-system-mips          qemu-system-sparc64
qemu-alpha qemu-mips64el qemu-sparc qemu-system-mips64 qemu-system-tricore
qemu-arm qemu-mipsel qemu-sparc32plus qemu-system-mips64el qemu-system-unicore32
qemu-armeb qemu-mipsn32 qemu-sparc64 qemu-system-mipsel qemu-system-x86_64
qemu-cris qemu-mipsn32el qemu-system-aarch64 qemu-system-moxie qemu-system-xtensa
qemu-i386 qemu-nbd qemu-system-alpha qemu-system-or32 qemu-system-xtensaeb
qemu-img qemu-or32 qemu-system-arm qemu-system-ppc qemu-tilegx
qemu-io qemu-ppc qemu-system-cris qemu-system-ppc64 qemu-unicore32
qemu-m68k qemu-ppc64 qemu-system-i386 qemu-system-ppc64le qemu-x86_64
qemu-make-debian-root qemu-ppc64abi32 qemu-system-lm32 qemu-system-ppcemb
qemu-microblaze qemu-ppc64le qemu-system-m68k qemu-system-sh4
qemu-microblazeel qemu-s390x qemu-system-microblaze qemu-system-sh4eb
qemu-mips qemu-sh4 qemu-system-microblazeel qemu-system-sparc

很多时候已经有现成的镜像和内核了

比如debian就提供了比较多

https://people.debian.org/~aurel32/qemu/

而且里面也给了启动方式,至于内核,32还是64什么的就自己选了

1
2
3
4
- qemu-system-arm -M versatilepb -kernel vmlinuz-2.6.32-5-versatile -initrd initrd.img-2.6.32-5-versatile -hda debian_squeeze_armel_standard.qcow2 -append "root=/dev/sda1"
- qemu-system-arm -M versatilepb -kernel vmlinuz-2.6.32-5-versatile -initrd initrd.img-2.6.32-5-versatile -hda debian_squeeze_armel_desktop.qcow2 -append "root=/dev/sda1"
- qemu-system-arm -M versatilepb -kernel vmlinuz-3.2.0-4-versatile -initrd initrd.img-3.2.0-4-versatile -hda debian_wheezy_armel_standard.qcow2 -append "root=/dev/sda1"
- qemu-system-arm -M versatilepb -kernel vmlinuz-3.2.0-4-versatile -initrd initrd.img-3.2.0-4-versatile -hda debian_wheezy_armel_desktop.qcow2 -append "root=/dev/sda1"

当然这里还有一些装好gdb和gef的镜像

https://blahcat.github.io/2017/06/25/qemu-images-to-play-with/

还要说的就是端口的映射,可以在上面指令的基础上加上下面这个

1
-redir tcp:22::22

不要图像界面可以下面这样,直接给完整示例吧

1
qemu-system-arm -M versatilepb -kernel vmlinuz-3.2.0-4-versatile -initrd initrd.img-3.2.0-4-versatile -hda debian_wheezy_armel_standard.qcow2 -append "root=/dev/sda1" -redir tcp:22::22 -redir tcp:10000::10000 -redir tcp:10001::10001 -redir tcp:10002::10002 -redir tcp:1616::1616 -nographic

退出当前虚拟机

ctrl + A 再按 X

打赏专区