树莓派 qemu-system-aarch64 安装Ubuntu arm虚拟机

1.安装qemu

推荐使用https://gitee.com/openfans-community/Debian-Pi-Aarch64镜像,自带qemu3.x版本。

2.下载Ubuntu arm 版镜像

https://ubuntu.com/download/server/arm

3.创建虚拟磁盘

qemu-img create ubuntu-image.img 10G

4.启动虚拟机开始安装步骤

sudo qemu-system-aarch64 \
-M virt-2.12 -smp 4 -m 1G -cpu host -enable-kvm \
-bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -device ramfb \
-device qemu-xhci,id=xhci -usb \
-device usb-kbd -device usb-mouse -device usb-tablet -k en-us \
-device virtio-blk,drive=system \
-drive if=none,id=system,format=raw,media=disk,file=/home/pi/ubuntu/ubuntu-image.img \
-device usb-storage,drive=install \
-drive if=none,id=install,format=raw,media=cdrom,file=/home/pi/ubuntu/ubuntu-20.10-live-server-arm64.iso \
-device virtio-net,disable-legacy=on,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::2222-:22 -vnc :3 

然后用vnc连接,端口5903

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 使用默认选项,一直下一步,开始安装

 安装完成后重启进入系统

5.移除安装镜像启动

sudo qemu-system-aarch64 \
-M virt-2.12 -smp 4 -m 1G -cpu host -enable-kvm \
-bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -device ramfb \
-device qemu-xhci,id=xhci -usb \
-device usb-kbd -device usb-mouse -device usb-tablet -k en-us \
-device virtio-blk,drive=system,bootindex=0 \
-drive if=none,id=system,format=raw,media=disk,file=/home/pi/ubuntu/ubuntu-image.img \
-device virtio-net,disable-legacy=on,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::2222-:22 -vnc :3

NOTE:

bootindex=0指定启动顺序

hostfwd=tcp::2222-:22 将虚拟机的22端口映射到物理机的2222端口

-vnc :3 vnc默认端口是从5000开始的,参数3表示5003端口

也可以将虚拟机安装到usb优盘中

-drive if=none,id=system,format=raw,media=disk,file=/dev/sda1 \

 

posted @ 2021-02-01 00:00  _DC  阅读(2968)  评论(0编辑  收藏  举报