Run QEMU under Ubuntu to simulate riscv64 and run Debian

1. Install QEMU

download link:

https://www.qemu.org/download/
It is recommended to choose a stable version, unzip it after downloading, and then make

wget https://download.qemu.org/qemu-8.0.3.tar.xz
tar xjvf qemu-8.0.3.tar.xz
cd qemu-8.0.3
./configure --enable-kvm --enable-virtfs
make
--enable-virtfs share files between user virtual machine and host machine

2. Install u-boot-qemu

sudo apt install u-boot-qemu

3. Download Debian’s riscv64 image

Download address: https://cdn.artifacts.gitlab-static.net/9d/f6/9df69d693033f3071b9dee279b40dead9517d1ec9a95eb4bf3404e5d8767b683/@final/4c/40/b1a5e7823e522f8e18d15a304 58eb6bf7a81b06fb4e5d1446abf0a994e8a?Expires=1693379985&KeyName=gprd-artifacts-cdn&Signature=v7OlQeXqgcjDlFjmMu38g7wZ2S4=

After downloading, unzip and get image.qcow2

4. Start Qemu

qemu-system-riscv64 -machine virt -cpu rv64 -m 8G -smp 4 -nographic \
    -append "console=ttyS0 rw root=/dev/vda1" \
    -device virtio-blk-device,drive=hd \
    -drive file=imge.qcow2,if=none,id=hd \
    -device virtio-net-device,netdev=net \
    -netdev user,id=net,hostfwd=tcp::2222-:22 \
    -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \
    -object rng-random,filename=/dev/urandom,id=rng \
    -device virtio-rng-device,rng=rng \
    -virtfs local,path=~/shared,mount_tag=host0,security_model=passthrough,id=host0 

5. Visit Debian

You can log in directly on Qemu, the account password is root: root

Guess you like

Origin blog.csdn.net/ctbinzi/article/details/132586232
run