.iso是电脑上光盘镜像(CD Mirror)的存储格式之一,因为其是根据ISO-9660有关CD-ROM文件系统标准存储的文件,所以通常在电脑中以后缀.iso命名,俗称iso镜像文件。
openstack支持从iso安装虚拟机。
1、先将下载好的iso镜像上传到glance
#!/bin/bash
source /root/admin-openrc
glance image-create --name centos7-iso \
--disk-format iso \
--container-format bare \
--file CentOS-7-x86_64-DVD-1908.iso \
--progress
+--------------------------------------+----------------------------------------------------------------------------------+
| Property | Value |
+--------------------------------------+----------------------------------------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-SRV-ATTR:host | controller02 |
| OS-EXT-SRV-ATTR:hostname | iso-test |
| OS-EXT-SRV-ATTR:hypervisor_hostname | controller02 |
| OS-EXT-SRV-ATTR:instance_name | instance-00000070 |
| OS-EXT-SRV-ATTR:kernel_id | |
| OS-EXT-SRV-ATTR:launch_index | 0 |
| OS-EXT-SRV-ATTR:ramdisk_id | |
| OS-EXT-SRV-ATTR:reservation_id | r-ki5kf104 |
| OS-EXT-SRV-ATTR:root_device_name | /dev/vda |
| OS-EXT-SRV-ATTR:user_data | - |
| OS-EXT-STS:power_state | 1 |
| OS-EXT-STS:task_state | - |
| OS-EXT-STS:vm_state | active |
| OS-SRV-USG:launched_at | 2020-02-14T08:01:49.000000 |
| OS-SRV-USG:terminated_at | - |
| accessIPv4 | |
| accessIPv6 | |
| config_drive | True |
| created | 2020-02-14T08:00:26Z |
| description | - |
| flavor | qos-test (f912f961-370a-4e3a-8287-348a4233e21a) |
| hostId | bd0c4cf41265f5e1e5411d45a3ba93aa309314b704539d31f63bcb2b |
| host_status | UP |
| id | a6a60048-cd98-4c6f-9044-f0ba465954a0 |
| image | Attempt to boot from volume - no image supplied |
| iso | |
| key_name | - |
| locked | False |
| metadata | {} |
| name | iso-test |
| net02 network | 10.0.53.142 |
| os-extended-volumes:volumes_attached | [{"id": "8f33330b-89b6-4d58-be8c-754436e780c9", "delete_on_termination": false}] |
| os-pci:pci_devices | [] |
| progress | 0 |
| security_groups | default |
| status | ACTIVE |
| tenant_id | 921ac80ffd364fc0b347ecc4e68ba5c5 |
| updated | 2020-02-14T08:01:49Z |
| user_id | ee34dd53da7b4ceaa62f0c2667edb4d6 |
+--------------------------------------+----------------------------------------------------------------------------------+
2、创建一个空盘的虚拟机
#!/usr/bin/env bash
source /root/admin-openrc
system_image_id=4e26cfb0-7539-46ca-af93-40af43cea2cf
vm_name=$1
nova boot \
--min-count 1 \
--max-count 1 \
--flavor 2 \
--block-device source=blank,dest=volume,size=20,bootindex=0 \
--availability-zone nova:controller02 \
--nic net-id=15445b21-3a06-4e54-8815-88f2c04cdb10 \
$vm_name
3、将iso挂载到虚拟机
nova iso-attach 6bc0f980-67bf-4cec-9d19-aac05b184b7f e8a23fe6-e061-420f-aacd-e510b7815892
nova iso-attach
4、重启虚拟机,此时会默认从光驱启动。
nova reboot 6bc0f980-67bf-4cec-9d19-aac05b184b7f
5、进入vnc安装操作系统
[root@controller01 ~]# nova get-vnc-console iso-test novnc
+-------+-----------------------------------------------------------------------------------+
| Type | Url |
+-------+-----------------------------------------------------------------------------------+
| novnc | https://10.0.51.108:7080/vnc_auto.html?token=b56a00dc-37e1-41a6-ac68-87c7d560aee8 |
+-------+-----------------------------------------------------------------------------------+
下面开始正常安装系统即可,注意此时要卸载iso,因为一般linux系统安装完后要重启,没有卸载的话,虚机默认优先从光驱启动,又会进入安装界面。
6、将iso从虚拟机上卸载。
nova iso-detach 6bc0f980-67bf-4cec-9d19-aac05b184b7f
虚拟机安装好后,可以通过快照或者volume来创建镜像,这样就可以通过镜像来创建此iso安装的虚拟机了。