update
This commit is contained in:
parent
e921e5a2f7
commit
1c92401de1
95
content/post/qemu.md
Normal file
95
content/post/qemu.md
Normal file
@ -0,0 +1,95 @@
|
||||
---
|
||||
title: "Qemu 启动 arm64 虚拟机"
|
||||
date: 2025-04-24T17:35:00+08:00
|
||||
lastmod: 2025-04-24T17:35:00+08:00
|
||||
tags: ["kvm", "虚拟化"]
|
||||
categories: ["kvm"]
|
||||
---
|
||||
|
||||
## 安装 qemu
|
||||
- 安装依赖
|
||||
```
|
||||
dnf install \
|
||||
gcc make cmake ninja-build \
|
||||
xz bzip2 \
|
||||
python3 perl-interpreter \
|
||||
glib2-devel pixman-devel zlib-devel \
|
||||
diffutils findutils
|
||||
```
|
||||
|
||||
- 编译 qemu
|
||||
```
|
||||
curl -LO https://download.qemu.org/qemu-6.2.0.tar.xz
|
||||
tar xf qemu-6.2.0.tar.xz
|
||||
cd qemu-6.2.0
|
||||
mkdir /opt/qemu-aarch64
|
||||
./configure --prefix=/opt/qemu-aarch64/ –-target-list=aarch64-softmmu
|
||||
make
|
||||
make install
|
||||
```
|
||||
|
||||
- 下载 efi 固件
|
||||
```
|
||||
curl -LO https://releases.linaro.org/components/kernel/uefi-linaro/16.02/release/qemu64/QEMU_EFI.fd
|
||||
```
|
||||
|
||||
## 创建 arm64 虚拟机
|
||||
- 下载 Rocky Linux 8 iso 镜像文件
|
||||
```
|
||||
curl -LO https://mirrors.nju.edu.cn/rocky/8.6/isos/aarch64/Rocky-8.6-aarch64-minimal.iso
|
||||
```
|
||||
|
||||
- 创建虚拟硬盘
|
||||
```
|
||||
mkdir /data/qemu
|
||||
/opt/qemu-aarch64/bin/qemu-img create rocky8-aarch64.img 6G
|
||||
```
|
||||
|
||||
- 创建虚拟机
|
||||
```
|
||||
/opt/qemu-aarch64/bin/qemu-system-aarch64 \
|
||||
-m 2048 \
|
||||
-cpu cortex-a57 \
|
||||
-smp 2 \
|
||||
-M virt \
|
||||
-bios QEMU_EFI.fd \
|
||||
-nographic \
|
||||
-drive if=none,file=Rocky-8.6-aarch64-minimal.iso,id=cdrom,media=cdrom \
|
||||
-device virtio-scsi-device \
|
||||
-device scsi-cd,drive=cdrom \
|
||||
-drive if=none,format=raw,file=/data/qemu/rocky8-aarch64.img,id=hd0 \
|
||||
-device virtio-blk-device,drive=hd0
|
||||
```
|
||||
|
||||
- 前台启动虚拟机,可以调整处理器核数和内存大小
|
||||
```
|
||||
/opt/qemu-aarch64/bin/qemu-system-aarch64 \
|
||||
-m 4096 \
|
||||
-cpu cortex-a57 \
|
||||
-smp 4 \
|
||||
-M virt -bios /opt/qemu-aarch64/utils/QEMU_EFI.fd \
|
||||
-drive if=none,format=raw,file=/data/qemu/rocky8-aarch64.img,id=hd0 \
|
||||
-device virtio-blk-device,drive=hd0 \
|
||||
-nographic \
|
||||
-display none
|
||||
```
|
||||
|
||||
- 后台启动虚拟机,可以调整处理器核数和内存大小
|
||||
```
|
||||
/opt/qemu-aarch64/bin/qemu-system-aarch64 \
|
||||
-m 4096 \
|
||||
-cpu cortex-a57 \
|
||||
-smp 4 \
|
||||
-M virt -bios /opt/qemu-aarch64/utils/QEMU_EFI.fd \
|
||||
-drive if=none,format=raw,file=/data/qemu/rocky8-aarch64.img,id=hd0 \
|
||||
-device virtio-blk-device,drive=hd0 \
|
||||
-net user,hostfwd=tcp::10022-:22 \
|
||||
-net nic \
|
||||
-display none \
|
||||
-daemonize
|
||||
```
|
||||
|
||||
## 参考
|
||||
- [https://programmersought.com/article/81835534690/](https://programmersought.com/article/81835534690/)
|
||||
- [https://blog.csdn.net/qq_41961459/article/details/119109622](https://blog.csdn.net/qq_41961459/article/details/119109622)
|
||||
|
Loading…
x
Reference in New Issue
Block a user