创建 Linux qcow2 格式虚拟机模板

2020-03-31 创建 Linux qcow2 格式虚拟机模板

FileInfo
Filename - 创建 Linux qcow2 格式虚拟机模板
Version - v1.1.2003(2020/03/31 ~ 2020/03/31)
Author - NUO standuke
Email - [email protected]
DescriptionKey - linux centos qcow2 cloudbase init openstack

需求

Openstack 虚拟化需要

工具准备

  • KVM 虚拟机,支持 VirtIO 即可
  • CentOS 系统安装光盘

开始制作

  1. 在 KVM 内安装好 CentOS 「cli/gui 都可以」

  2. 自定义镜像

  3. 安装 cloud-init

  4. 修改 cloud-init 配置文件 /etc/cloud/conf.cfg

Tips

guestfish

参考链接:here
http://libguestfs.org/guestfish.1.html
guestfish is an interactive shell that you can use from the command line or from shell scripts to access guest virtual machine file systems. All of the functionality of the libguestfs API is available from the shell.
We will use the guestfish tool to modify the password details and Changing the ‘root’ password on kvm qcow2 (images) for OpenStack environments.

  • 安装工具
yum -y install libguestfs libguestfs-tools*
  • 生成加密后的密码
openssl passwd -1 "password"
  • 进入镜像的文件系统,修改密码
Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.

Type: ‘help’ for help on commands
‘man’ to read the manual
‘quit’ to quit the shell

 run
> list-filesystems
/dev/sda1: xfs
> mount /dev/sda1 /
> vi /etc/shadow (update the encrupted password)
> quit

Vmware 扩展磁盘空间

在虚拟机里操作的时候遇到磁盘不足时,可以使用 VMware 自带的「扩展磁盘容量」

  • 虚拟机配置页面扩展磁盘容量
  • 进入虚拟机扩展文件系统

参考资料
Linux 系统安装 cloud-init
https://cloud.tencent.com/document/product/213/12587#SoftSources

你可能感兴趣的:(创建 Linux qcow2 格式虚拟机模板)