x86_64机器上用qemu安装rhel-7.4-aarch64
2019-09-27
qemu要运行aarch64必须先安装aarch64支持:qemu-system-aarch64,centos/rhel下该包需要自己编译安装,Fedora源带该包,为简单操作本文直接在Fedora上实践
宿主机选用的Fedora版本 : Fedora-Server-dvd-x86_64-30-1.2.iso
虚拟机选用的rhel-7.4-aarch64版本 : rhel-alt-server-7.4-aarch64-dvd.iso
(用centos的aarch64也可以)
一. 配置宿主机桥接
配置桥接目的是在后面安装好的aarch64系统里面可以配置和宿主机Fedora在同一个网段的IP,如果不需要桥接,该章节可以跳过
宿主机原始状态
[root@fedora-30 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 52:54:00:c2:9f:3c brd ff:ff:ff:ff:ff:ff
inet 10.10.10.33/24 brd 10.10.10.255 scope global noprefixroute ens3
valid_lft forever preferred_lft forever
inet6 fe80::eb55:dc8:1ca0:bb74/64 scope link noprefixroute
valid_lft forever preferred_lft forever
编辑ifcfg-br0/ifcfg-ens3(ifcfg-br0默认不存在,需要创建),ifcfg-ens3文件名根据你的实际环境修改,xxx的地方需要根据你的实际情况修改
[root@fedora-30 ~]# cat /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.10.10.33 # xxx
NETMASK=255.255.255.0 # xxx
GATEWAY=10.10.10.254 # xxx
DNS1=114.114.114.114 # xxx
[root@fedora-30 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens3
TYPE=Ethernet
NAME=ens3 # xxx
DEVICE=ens3 # xxx
BRIDGE=br0
ONBOOT=yes
Fedora 30已经不再推荐使用network
服务,所以默认系统/etc/sysconfig/network-scripts
下只有网卡配置文件,没有ifup/ifdown这些脚本,可以通过以下方式安装回来并重启网络
[root@fedora-30 ~]# yum install network-scripts
[root@fedora-30 ~]# systemctl restart network
正常情况下应该状态如下
[root@fedora-30 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
link/ether 52:54:00:c2:9f:3c brd ff:ff:ff:ff:ff:ff
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 52:54:00:c2:9f:3c brd ff:ff:ff:ff:ff:ff
inet 10.10.10.33/24 brd 10.10.10.255 scope global br0
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:fec2:9f3c/64 scope link
valid_lft forever preferred_lft forever
二. 安装qemu-aarch64支持
下面的包在默认的源里面都有,不要修改或者额外新加源
[root@fedora-30 ~]# yum install qemu-system-aarch64 libvirt virt-install virt-manager
[root@fedora-30 ~]# systemctl start libvirtd
三. 创建虚拟机
PS:不要把iso和虚拟机镜像放到/root下,否则会因为权限问题无法安装
创建虚拟机文件
[root@fedora-30 ~]# qemu-img create -f qcow2 /data/rhel-74-aarch64.qcow2 10g
图形化安装方式
因为要用到vnc所以需要把防火墙关闭
[root@fedora-30 ~]# systemctl stop firewalld
[root@fedora-30 ~]# systemctl disable firewalld
[root@fedora-30 ~]# virt-install --name rhel-74-aarch64 --ram 2048 --vcpus=2 --arch aarch64 --boot uefi --disk path=/data/rhel-74-aarch64.qcow2 --cdrom /data/rhel-alt-server-7.4-aarch64-dvd.iso --vnc --vnclisten=0.0.0.0 --noautoconsole
Starting install...
Domain installation still in progress. You can reconnect to
the console to complete the installation process.
若上步没有报错,即可通过如下命令查看vnc port,例如如下:0
,然后用vnc客户端访问10.10.10.33:0即可
,后面的安装步骤和安装centos-x86_64几乎一样不再介绍
[root@localhost ~]# virsh vncdisplay rhel-74-aarch64
:0

字符界面安装方式
[root@fedora-30 ~]# virt-install --name rhel-74-aarch64 --ram 2048 --vcpus=2 --arch aarch64 --boot uefi --disk path=/data/rhel-74-aarch64.qcow2 --cdrom /data/rhel-alt-server-7.4-aarch64-dvd.iso
