前言
在qemu中运行mips架构的debian linux可以用于在没有mips架构的硬件时做一些相关测试。
本实验环境:
本机:OSX 10.14.4
虚拟机:Ubuntu 16.04
debian linux: 32bit 大端序
步骤
如果不需要最新版本的qemu,可以直接通过apt-get安装
sudo apt-get install qemu-system-mips
如果从官网下载则:
./configure
make
make install #root
从Debian.org下载mips linux最新的版本stretch(这里被坑了两次,一开始下载的squeeze和wheeze都因为没有继续维护而不能用)的kernel和image。我选择的是32位版本,则是mips命名的文件。
运行qemu的指令为:
qemu-system-mips -nographic -M malta -kernel vmlinux-4.9.0-4-5kc-malta.mips.stretch -hda debian-stretch-mips.qcow2 -append "root=/dev/sda1 console=tty0"
当启动完成后,则可得到一个shell,使用root用户,密码为root。
当结束使用的时候,可以执行halt
指令关机,但是实际上是重启,会重新看到qemu启动linux的状态,在此时按下ctrl+a
再按下x,即可终止qemu。
配置网络
使用如下指令对qemu的22端口与虚拟机的10022端口做映射
qemu-system-mips -nographic -M malta -kernel vmlinux-4.9.0-4-5kc-malta.mips.stretch -hda debian-stretch-mips.qcow2 -net user,hostfwd=tcp::10022-:22 -net nic -append "root=/dev/sda1 console=tty0"
从而可以使用ssh访问虚拟机:
ssh root@localhost -p 10022