概述
Alibaba Cloud Linux 3 兼容 CentOS 8、RHEL 8 软件生态, 其最大的优势之一是能作为 CentOS8 的替代方案, 可免费使用该系统镜像, 并免费获得阿里云针对该操作系统的长期支持 Alibaba Cloud Linux 3(Linux Kernel 5.10.84)镜像目前只支持 KVM 虚拟机, 镜像本身不可直接启动虚拟机,需要配置引导镜像
生成引导镜像
本地生成引导镜像 seed.qcow2, 用于虚拟机安装 Alibaba Cloud Linux 3 系统镜像后, 初始化其系统配置参数
1、本地生成引导镜像 seed.qcow2
mkdir -p alinux/seed && cd alinux/seedtouch meta-data user-data2、cat meta-data
#cloud-config#vim:syntax=yamllocal-hostname: t33、cat user-data
#cloud-config#vim:syntax=yaml# 添加一个名为 alinux 的账号,并且可以执行sudo命令users: - default - name: root sudo: ['ALL=(ALL) NOPASSWD:ALL'] plain_text_passwd: rootroot lock_passwd: false# 添加 Alibaba Cloud Linux 3 的 YUM 源yum_repos: alinux3-module: name: alinux3-module baseurl: https://mirrors.aliyun.com/alinux/$releasever/module/$basearch/ enabled: 1 gpgcheck: 1 gpgkey: https://mirrors.aliyun.com/alinux/$releasever/RPM-GPG-KEY-ALINUX-3 alinux3-updates: name: alinux3-updates baseurl: https://mirrors.aliyun.com/alinux/$releasever/updates/$basearch/ enabled: 1 gpgcheck: 1 gpgkey: https://mirrors.aliyun.com/alinux/$releasever/RPM-GPG-KEY-ALINUX-3 alinux3-plus: name: alinux3-plus baseurl: https://mirrors.aliyun.com/alinux/$releasever/plus/$basearch/ enabled: 1 gpgcheck: 1 gpgkey: https://mirrors.aliyun.com/alinux/$releasever/RPM-GPG-KEY-ALINUX-3 alinux3-powertools: name: alinux3-powertools baseurl: https://mirrors.aliyun.com/alinux/$releasever/powertools/$basearch/ gpgcheck: 1 enabled: 1 gpgkey: https://mirrors.aliyun.com/alinux/$releasever/RPM-GPG-KEY-ALINUX-3 alinux3-os: name: alinux3-os baseurl: https://mirrors.aliyun.com/alinux/$releasever/os/$basearch/ gpgcheck: 1 enabled: 1 gpgkey: https://mirrors.aliyun.com/alinux/$releasever/RPM-GPG-KEY-ALINUX-34、利用 cloud-utils 生成引导镜像 seed.qcow2
yum install -y cloud-utilscloud-localds -d qcow2 seed.qcow2 user-data meta-datacp seed.qcow2 /home/data/vm/seed.qcow2创建虚拟机
1、下载 Alibaba Cloud Linux 3 镜像, 创建虚拟机 t3
wget https://alinux3.oss-cn-hangzhou.aliyuncs.com/aliyun_3_x64_20G_nocloud_alibase_20211025.qcow2cp aliyun_3_x64_20G_nocloud_alibase_20211025.qcow2 /home/data/vm/t3.qcow22、定义 kvm 虚拟机 virsh define t3.xml
<!-- cat t3.xml --><domain type='kvm'> <name>t3</name> <memory>4194304</memory><!-- 4 GB内存 --> <vcpu>2</vcpu> <cpu mode='custom' match='exact' check='partial'> <model fallback='allow'>Broadwell</model> </cpu> <os> <!-- 如果是ARM64架构的服务器,则需设置为arch='aarch64' --> <type arch='x86_64'>hvm</type> <boot dev='hd'/> </os> <clock sync="localtime"/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <!-- 请根据不同的操作系统设置对应的kvm路径。例如:Ubuntu对应的kvm路径是/usr/bin/kvm --> <emulator>/usr/libexec/qemu-kvm</emulator> <!-- 请根据镜像格式设置下面的type参数:qcow2对应type='qcow2'、vhd对应type='vpc' --> <disk type='file' device='disk'> <!-- 如果要创建qcow2快照,需要关闭dataplane --> <driver name='qemu' type='qcow2' cache='none' dataplane='on' io='native'/> <!-- 填写Alibaba Cloud Linux 3镜像的绝对路径 --> <source file='/home/data/vm/t3.qcow2'/> <target dev='vda' bus='virtio'/> </disk> <!-- 加入seed.img的信息 --> <disk type='file' device='disk'> <driver name='qemu' type='raw'/> <!-- 填写seed镜像的绝对路径 --> <source file='/home/data/vm/seed.img'/> <target dev='vdb' bus='virtio'/> </disk> <interface type='bridge'> <!-- 需要提前创建网桥 br2 --> <source bridge='br2'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/> </interface> <console type='pty'> <target type='virtio' port='0'/> </console> <video> <model type='cirrus' vram='9216' heads='1'/> <alias name='video0'/> </video> <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='59163' autoport='no'/> </devices></domain>