ubuntu 20.04 通过qemu实现aarch64虚拟化

一、windows下安装vmware虚拟机

二、ubuntu下载地址
https://mirrors.tuna.tsinghua.edu.cn/ubuntu-releases/20.04/ubuntu-20.04.3-live-server-amd64.iso

三、vmware中新建虚拟机,并使用ubuntu-20.04.3-live-server-amd64.iso作为启用盘
。。。在虚拟机中安装ubuntu(略)

四、配置ssh(如果ssh登录不上时配置)

  • 修改openssh的配置
    vi /etc/ssh/sshd_config
KexAlgorithms [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
systemctl restart sshd

五、配置虚拟机的网络为br0

cat  > /etc/netplan/01-network-manager-all.yaml << 'EOF'
network:
  version: 2
  renderer: networkd
  ethernets:
    ens32:
      dhcp4: no
      dhcp6: no
  bridges:
    br0:
      addresses: [192.168.11.220/24]
      dhcp4: no
      dhcp6: no
      gateway4: 192.168.11.2
      nameservers:
        addresses: [192.168.11.2,223.5.5.5]
      interfaces:
         - ens32
EOF

重启网络

netplan apply

六、在虚拟机中安装qemu

apt-get update -y
apt install net-tools lrzsz wget unzip -y
apt openssh-server -y
apt install qemu -y
apt-get install qemu-kvm -y
apt install qemu-system-arm -y
apt-get install bridge-utils

七、下载centos7(aarch64) 和UEFI固件

#下载UEFI固件
wget http://releases.linaro.org/components/kernel/uefi-linaro/16.02/release/qemu64/QEMU_EFI.fd

#下载centos7 arm64
wget https://mirrors.tuna.tsinghua.edu.cn/centos-altarch/7.9.2009/isos/aarch64/CentOS-7-aarch64-Minimal-2009.iso

#备选UEFI固件
#yum install http://mirror.centos.org/altarch/7/os/aarch64/Packages/AAVMF-20180508-6.gitee3198e672e2.el7.noarch.rpm

八、创建centos7(aarch7)虚拟机
把下载好的CentOS-7-aarch64-Minimal-2009.iso放到/test01目录下

#切换到root下
sudo su -

mkdir /test01
cd /test01
#创建磁盘
qemu-img create -f qcow2 centos-arm64.qcow2 40G

cat > start.sh << 'EOF'
#!/bin/bash
#创建桥接网络

#visodu
#szgd ALL=(ALL) NOPASSWD: ALL

sudo ip tuntap add dev tap0 mod tap
sudo brctl addif br0 tap0
sudo ifconfig tap0 0.0.0.0 promisc up
sudo brctl showstp br0


SYSTEMISO=$(ls *.iso)
DISKFILE=$(ls *.qcow2)

qemu-system-aarch64 -m 4096 -cpu cortex-a72 -smp 4 -M virt \
-bios QEMU_EFI.fd \
-nographic \
-drive if=none,file=${DISKFILE},id=hd0 \
-device virtio-blk-device,drive=hd0 \
-device virtio-scsi-device \
-net nic,macaddr=`dd if=/dev/urandom count=1 2>/dev/null | md5sum | sed 's/^\(.\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\14:\2:\3:\4:\5:\6/g'` \
-net tap,ifname=tap0,script=no,downscript=no \

#    -drive if=none,file=${SYSTEMISO},id=cdrom,media=cdrom \
#    -device scsi-cd,drive=cdrom \

EOF

你可能感兴趣的:(运维工具,ubuntu,ssh,服务器)