通过qemu虚拟机使用 LoongArchLinux镜像
在 @yetist 维护的LoongArchLinux仓库中,镜像目录(系统镜像,不是安装镜像ISO)录里,根据readme,下载并在qemu中运行LoongArchLinux。
试了mate和xfce,前者太简陋,后者好看,推荐后者。
步骤:
1. 安装qumu。我用的archlinux,官方仓库的最新版 extra/qemu-full 8.0.2-1 早已支持loongarch
sudo pacman -Sy qemu-full
2. 创建想放镜像的路径
mkdir -p ~/Builds/loongarch
cd ~/Builds/loongarch
3. 根据镜像目录中的README,下载固件、镜像到目标路径
根据README,qemu 版本 >= 7.2,安装 QEMU_EFI_7.2.fd
桌面环境选择了好看的xfce
注意镜像的后缀qcow2.zst,zst是压缩格式,下载后解压到当前目录。
4.根据镜像目录中的README中的命令运行qemu
qemu-system-loongarch64 \
-m 4G \
-cpu la464-loongarch-cpu \
-machine virt \
-smp 4 \
-bios ~/Builds/loongarch/QEMU_EFI_7.2.fd \
-serial stdio \
-device virtio-gpu-pci \
-net nic -net user \
-device nec-usb-xhci,id=xhci,addr=0x1b \
-device usb-tablet,id=tablet,bus=xhci.0,port=1 \
-device usb-kbd,id=keyboard,bus=xhci.0,port=2 \
-hda ~/Builds/loongarch/archlinux-mate-2023.05.10-loong64.qcow2
注意 把~/Builds/loongarch/
换为你自己的路径。
启动后就能进入grub, 然后到登录界,账号密码都是 loongarch
5. 为了方便,写个脚本把上面那么长的命令存起来
sudo vim /usr/bin/lxfce
写入内容如下:
#!/usr/bin/bash
qemu-system-loongarch64 \
-m 4G \
-cpu la464-loongarch-cpu \
-machine virt \
-smp 4 \
-bios ~/Builds/loongarch/QEMU_EFI_7.2.fd \
-serial stdio \
-device virtio-gpu-pci \
-net nic -net user \
-device nec-usb-xhci,id=xhci,addr=0x1b \
-device usb-tablet,id=tablet,bus=xhci.0,port=1 \
-device usb-kbd,id=keyboard,bus=xhci.0,port=2 \
-hda ~/Builds/loongarch/archlinux-mate-2023.05.10-loong64.qcow2
:wq
保存并退出
赋予执行权限:
sudo chmod 755 /usr/bin/lxfce
下次输入 lxfce
就直接运行虚拟机了
杜比
很不错!
Curious
很好!很高兴看到7.2之后的qemu也能运行了
eric_young
请问各位, 我在ubuntu上的qemu 7.2(从源码编译的)按照这个教程搞, 会卡在:
Loading Linux linu
Loading initial ramdisk
这个问题有没有头绪?
only998
我用windows x64的qemu8.1 8.2,用的8.1的固件,启动龙芯网站上下的loongnix系统也是卡在这,估计只能上新世界的镜像。
ghw
only998 我也看不懂,但是新世界的主机是能跑旧世界的 带 --accel kvm
TF-zhong
Arch Linux 里这个 QEMU_EFI_7.2.fd 和 新的 8.2 的版本都有问题
一是启动时间比较长, 是否 编译的 debug 版本
二个问题是 启动后 vcpu 个数是有了, 但是 只有一个 vcpu 是 On-line 状态的 , 除了 lscpu 能看到有例如 4 个 cpu , 但是 3 个离线, 其他方式 neofetch , gnome-system-monitor , htop 都只能看到 一个 vcpu
使用 https://github.com/loongson/Firmware/tree/main/LoongArchVirtMachine 里的 edk2 code. fd 则没有上述问题, 而且虚拟机启动明显变快
TF-zhong 改用了TF-zhong提到的edk2 code. fd,确实快了!
好久没用,今天打包需要登录上去Syu后重启虚拟机,黑屏。
下载更换最新的QEMU_EFI_8.1.fd 后能上去了。
更换方法:在启动脚本中
-bios ~/Builds/loongarch/QEMU_EFI_7.2.fd \
旧fd地址改为新的
-bios ~/Builds/loongarch/QEMU_EFI_8.1.fd \
hzleihuan
这个不错,点赞收藏一下