Windows机器,vmware虚拟机里是centos8.3.2011,在centos8里安装qemu后,安装aarch64架构的centos7系统
需要下载的软件
https://www.realvnc.com/download/file/viewer.files/VNC-Viewer-6.20.529-Windows.exe # vnc连接qemu虚拟机
wget https://mirrors.tuna.tsinghua.edu.cn/centos-altarch/7.9.2009/isos/aarch64/CentOS-7-aarch64-Minimal-2009.iso
yum install http://mirror.centos.org/centos/8/AppStream/aarch64/os/Packages/edk2-aarch64-20200602gitca407c7246bf-3.el8.noarch.rpm # aarch64的efi,类似bios启动文件 /usr/share/AAVMF/AAVMF_CODE.fd
wget https://download.qemu.org/qemu-4.2.0.tar.xz # 需要编译 qemu-system-aarch64,才能支持aarch64指令
安装过程,vnc连接后,在centos7图形按照界面的网络里,选择ON,开机启动网络,qemu的网络默认为nat,192.168.122网段,qemu的宿主机就是192.168.122.1,可以直接ssh连接到qemu的虚拟机里
yum groupinstall 'Development Tools' -y
yum groupinstall "Virtualization Host" -y
systemctl enable libvirtd
systemctl start libvirtd
usermod -aG libvirt $(whoami)
yum install virt-install virt-viewer virt-manager -y
reboot
# 编译qemu-system-aarch64
tar xf qemu-4.2.0.tar.xz
cd qemu-4.2.0/
yum install python2 zlib-devel glib2-devel pixman-devel -y
./configure --target-list=aarch64-softmmu --prefix=/usr
make -j8
make install # default location /usr/local/bin/qemu-system-aarch64
setenforce 0
# 下面运行很慢,耐心等待
virt-install \
--name centos-7-aarch64 --ram 2048 --arch aarch64 \
--boot uefi --disk size=10 \
--graphics vnc,listen=0.0.0.0,port=5900 \
--cdrom /mnt/hgfs/share/CentOS-7-aarch64-Minimal-2009.iso
# 使用上面下载的vnc viewer 连接 ip:5900 看看qemu虚拟机窗口,在这里面图像安装centos7
# /var/lib/libvirt/images/centos-7-aarch64.qcow2 # 上面自动创建的虚拟磁盘路径
pidof qemu-system-aarch64|xargs kill -9 # 杀掉虚拟机进程
virsh undefine centos-7-aarch64 --remove-all-storage --nvram # 卸载,删除
virsh --connect qemu:///system start centos-7-aarch64 # 启动
直接安装命令,执行后,会在当前终端显示 txt 版本的安装选项
qemu-img create centos7-arm64.img 16G
qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt \
-bios /usr/share/AAVMF/AAVMF_CODE.fd \
-nographic \
-drive if=none,file=CentOS-7-aarch64-Minimal-2009.iso,id=cdrom,media=cdrom \
-device virtio-scsi-device -device scsi-cd,drive=cdrom \
-drive if=none,file=centos7-arm64.img,id=hd0,format=raw \
-device virtio-blk-device,drive=hd0
-net user,hostfwd=tcp::10022-:22
-net nic
# 在vmware里的宿主机centos8上执行,开启ssh转发,windows访问centos8的222端口,会转发到192.168.122.198的22端口
ssh -L 0.0.0.0:222:localhost:22 root@192.168.122.198