设为首页 加入收藏

TOP

KVM导入Ubuntu/Centos Cloud Image创建虚机及调整磁盘大小(三)
2023-07-23 13:35:50 】 浏览:276
Tags:KVM 导入 Ubuntu/Centos Cloud Image
ssh-import-id (<module 'cloudinit.config.cc_ssh_import_id' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_ssh_import_id.py'>) failed ci-info: +++++++++++++++++++++++++++++++++Authorized keys from /home/ubuntu/.ssh/authorized_keys for user ubuntu+++++++++++++++++++++++++++++++++ ci-info: +---------+-------------------------------------------------------------------------------------------------+---------+----------------+ ci-info: | Keytype | Fingerprint (sha256) | Options | Comment | ci-info: +---------+-------------------------------------------------------------------------------------------------+---------+----------------+ ci-info: | ssh-rsa | 33:11:22:d7:b1:f9:83:3b:b8:94:9f:f3:33:33:33:33:12:12:8f:d4:34:2e:60:12:12:12:ae:12:12:12:d4:60 | - | milton@somewhe | ci-info: +---------+-------------------------------------------------------------------------------------------------+---------+----------------+

使用显示的IP, 以及之前配置的私钥就可以直接登录

一个完整的新虚机安装流程

Copy and resize image to 50GB

sudo cp /data/backup/CentOS-7-x86_64-GenericCloud.qcow2c vm_centos7a.qcow2
qemu-img info vm_centos7a.qcow2
sudo qemu-img resize vm_centos7a.qcow2 50G
# double check
qemu-img info vm_centos7a.qcow2

Prepare 2 files

metadata.yaml

instance-id: iid-local02
local-hostname: vm_u2204b
  • change instance-id to a different id
  • change local-hostname to the virtual machine hostname

user-data.yaml
The following config will

  • create default users and
  • create a additional sudo user milton
  • enable password login
#cloud-config
users:
  - default
  - name: milton
    groups: [sudo]
    sudo: ALL=(ALL) NOPASSWD:ALL
    shell: /bin/bash
    lock_passwd: false
    plain_text_passwd: ubuntu
chpasswd: 
  expire: False
ssh_pwauth: True
  • -default is the default cloud-init users (by default it is user named ubuntu)
  • users - name your user name
  • users - shell must specified, or no shell presents
  • users - lock_passwd set it to false to allow login
  • users - plain_text_passwd use this to set the user password
  • chpasswd and ssh_pwauth

seed.img

cloud-localds seed.img user-data.yaml metadata.yaml

copy the ubuntu cloud image to vms folder, and resize it to 50GB

cd /vms/
sudo cp /data/backup/ubuntu-22.04-minimal-cloudimg-amd64.img vm_u2204b.img
qemu-img info vm_u2204b.img 
sudo qemu-img resize vm_u2204b.img 50g
# recheck
qemu-img info vm_u2204b.img 

Then start to install

virt-install --name vm_u2204b  --vcpus 2 --memory 4096 --graphics none --import --os-variant ubuntu22.04 --network bridge=br0,model=virtio --disk /vms/vm_u2204b.img --disk /vms/seed.img

参考

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇LNMP简介 下一篇linux包管理器rpm和dpkg的使用说明

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目