制作OpenStack云平台centos6.5镜像

时间:2023-03-09 03:52:14
制作OpenStack云平台centos6.5镜像

创建虚拟镜像

# qemu-img create -f raw Cloud_Centos6.5_64bit.img 10G

[root@localhost ~]# ll /opt/CentOS-6.5-x86_64-bin_DVD.iso
-rw-r--r-- root root Aug /opt/CentOS-6.5-x86_64-bin_DVD.iso
[root@localhost ~]#
[root@localhost ~]# cd /tmp/
[root@localhost tmp]#
[root@localhost tmp]# qemu-img create -f raw Cloud_Centos6.5_64bit.img 10G
Formatting 'Cloud_Centos6.5_64bit.img', fmt=raw size=
[root@localhost tmp]#
[root@localhost tmp]# ll Cloud_Centos6.5_64bit.img
-rw-r--r-- root root Jan : Cloud_Centos6.5_64bit.img
[root@localhost tmp]#

创建KVM虚拟机,并启动

# virt-install --name Cloud_Centos6.5_64bit --ram 1024 --vcpus=1 --disk path=Cloud_Centos6.5_64bit.img --network network:default,model=virtio --arch=x86_64 --os-type=linux --os-variant=rhel6 --graphics vnc,port=5910 --cdrom /opt/CentOS-6.5-x86_64-bin_DVD.iso

[root@localhost tmp]# virt-install --name Cloud_Centos6.5_64bit --ram  --vcpus= --disk path=Cloud_Centos6.5_64bit.img --network network:default,model=virtio --arch=x86_64 --os-type=linux --os-variant=rhel6 --graphics vnc,port= --cdrom /opt/CentOS-6.5-x86_64-bin_DVD.iso 

Starting install...
Creating domain... | B :
Cannot open display:
Run 'virt-viewer --help' to see a full list of available command line options
Domain installation still in progress. You can reconnect to
the console to complete the installation process.
[root@localhost tmp]#

制作OpenStack云平台centos6.5镜像

制作OpenStack云平台centos6.5镜像

制作OpenStack云平台centos6.5镜像

[root@localhost tmp]# virsh list --all
Id Name State
----------------------------------------------------
- centos7 shut off
- Cloud_Centos6.5_64bit shut off
- Cloud_win7_64bit shut off [root@localhost tmp]#
[root@localhost tmp]# virsh start Cloud_Centos6.5_64bit
Domain Cloud_Centos6.5_64bit started [root@localhost tmp]#
[root@localhost tmp]# virsh list --all
Id Name State
----------------------------------------------------
Cloud_Centos6.5_64bit running
- centos7 shut off
- Cloud_win7_64bit shut off [root@localhost tmp]#

修改centos6.5虚拟机的网卡,并重启

制作OpenStack云平台centos6.5镜像

查看IP地址

制作OpenStack云平台centos6.5镜像

关机shutdown

制作OpenStack云平台centos6.5镜像

转换格式

# qemu-img convert -f raw -O qcow2 Cloud_Centos6.5_64bit.img Cloud_Centos6.5_64bit.qcow2

制作OpenStack云平台centos6.5镜像

[root@localhost tmp]# ll
total
-rw-r--r-- root root Jan : Cloud_Centos6.5_64bit.img
-rw-r--r-- root root Jan : Cloud_Centos6.5_64bit.qcow2

上传到OpenStack中

# glance image-create --name Cloud_Centos6.5_64 --disk-format qcow2 --container-format bare --is-public true --progress < /tmp/Cloud_Centos6.5_64bit.qcow2

[root@controller ~]# glance image-create --name Cloud_Centos6.5_64 --disk-format qcow2 --container-format bare --is-public true --progress < /tmp/Cloud_Centos6.5_64bit.qcow2
[=============================>] %
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | d6e6a71c69f1996350970489f9513402 |
| container_format | bare |
| created_at | --19T19:: |
| deleted | False |
| deleted_at | None |
| disk_format | qcow2 |
| id | fa28fbc9-cd3f-45f7-bb94-8fc8a09fc95c |
| is_public | True |
| min_disk | |
| min_ram | |
| name | Cloud_Centos6.5_64 |
| owner | 78f68e3b1a9a4e99818901638995aa36 |
| protected | False |
| size | |
| status | active |
| updated_at | --19T19:: |
| virtual_size | None |
+------------------+--------------------------------------+
[root@controller ~]#

完毕