1.sudo apt-get install qemu-system-arm
2.编译kernel:
下载个linux源码;比如linux-5.4
export ARCH=arm64
export CROSS_COPILE=aarch64-linux-gnu-
make defconfig
make menuconfig
make -j8 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
3.准备rootfs:
qemu-img create -f raw disk.img 512M
mkfs -t ext4 ./disk.img
mkdir tmpfs
sudo mount -o loop ./disk.img tmpfs/
sudo cp -r rootfs/* tmpfs/
sudo umount tmpfs
4.启动;
qemu-system-aarch64 -machine virt
-cpu cortex-a53
-nographic
-smp 2
-m 2048
-kernel ./Image
-append ;root=/dev/vda console=ttyAMA0; -hda ./disk.img