智简魔方文档

1 新版本镜像制作教程(非注入方式)

本文整理智简魔方云平台中“1 新版本镜像制作教程(非注入方式)”相关的配置、操作或问题处理内容,供管理员和运维人员按原文步骤查阅与执行。

# Windows 镜像制作

1、正常安装 windows_server 版本,

2、登录系统,下载如下两个软件(cloudbase-init, qemu-guest-agent),并点击默认安装,下面是下载地址

http://mirror.cloud.idcsmart.com/cloud/images/init-tools/CloudbaseInitSetup_1_1_2_x64.msi

http://mirror.cloud.idcsmart.com/cloud/images/init-tools/qemu-ga-x86_64.msi

3、将下面两个的配置文件下载并放置到镜像的目录: C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf

如下是配置文件下载链接: http://mirror.cloud.idcsmart.com/cloud/images/init-tools/cloudbase-init.conf http://mirror.cloud.idcsmart.com/cloud/images/init-tools/cloudbase-init-unattend.conf

4、关闭防火墙

5、关机,制作完成,得到的 qcow2 就是云镜像;

# Linux 镜像制作

使用官方标准 ISO 安装(linux 系统有很多,命令各不相同 但一定要安装的组件 sfdisk growpart cloud-init qemu-guest-agent)

根据需要关闭软件(不同系统不同命令): (CentOS 请一定关闭 SElinux),NetworkManager,iptables,firewalld

安装必须的工具(不同系统不同命令): cloud-init, qemu-guest-agent

根据需要安装软件,比如以下软件(不同系统不同命令): vim, curl, wget, net-tools

1、系统安装要求:

最小化、上海时区、语言英文、关闭 kdump、不锁定 root、不禁止 root 密码登录

2、关闭防火墙

systemctl stop firewalld
systemctl disable firewalld
sed -i '/^SELINUX=/ s/enforcing/disabled/g' /etc/selinux/config

3、设置时区

timedatectl set-timezone Asia/Shanghai

4、安装云相关组件及附件组件

dnf install util-linux cloud-utils-growpart -y
dnf install qemu-guest-agent cloud-init -y

dnf install vim curl wget net-tools chrony -y

5、配置/etc/ssh/sshd_config 中的选项

找到选项: PermitRootLogin yes     如果选项前有#号就去掉#号再修改值为 yes
找到选项: PasswordAuthentication yes    如果选项前有#号就去掉#号再修改值为 yes

# 若是ubuntu 需要把  执行 rm /etc/ssh/sshd_config.d/* -rf

6、编辑 cloud-init 配置文件 /etc/cloud/cloud.conf

将选项 disable_root: 0       # 原始值为1, 改为0. 打开root登录
将选项 ssh_pwauth: 1        #原始值为0, 改为1. 开启密码登录

system_info:
  default_user:
    name: centos << 此处改为 root
    lock_passwd: true << 此处改为 false
    gecos: Cloud User
    groups: [adm, systemd-journal]
    sudo: ["ALL=(ALL) NOPASSWD:ALL"]
    shell: /bin/bash
  distro: rhel
  paths:
    cloud_dir: /var/lib/cloud
    templates_dir: /etc/cloud/templates
  ssh_svcname: sshd

7、清理镜像

CentOS 清除多余网卡配置 /etc/sysconfig/network-scripts/ifcfg-[eth|eno 等网卡对应名称的文件](一定要保留 ifcfg-lo)。

清理 root 目录:

rm ~/*

清理 history:

rm ~/.bash_history && history -c

8、关机后压缩镜像,得到的 qcow2 就是制作好的镜像

shutdown -h now
qemu-img convert -p -c -O qcow2 vm-205-disk-0.qcow2 CentOS-9_x64.qcow2