参考链接:
- https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/OpenStack/page/Creating+qcow2+CentOS+Image+for+OpenStack
- http://docs.openstack.org/image-guide/content/centos-image.html
- http://www.it165.net/os/html/201309/6121.html
- https://answers.launchpad.net/nova/+question/226471
- http://ssms.cs2c.com.cn/otrs/pc.pl?Action=PublicFAQZoom;ItemID=10224;ZoomBackLink=QWN0aW9uPVB1YmxpY0ZBUUV4cGxvcmVyO0NhdGVnb3J5SUQ9MTQ7U29ydEJ5PVRpdGxlO09yZGVy%0APVVwO1N0YXJ0SGl0PTI2MDE%3D%0A;
使用ISO镜像制作适用于OpenStack的云镜像
资源:
- ISO镜像文件,此处选择RedHat Enterprise Linux 5.5 x86_64 ISO镜像文件;
- 支持qemu-kvm的Linux实体机;
注意:
经验证,RHEL5.5不支持在线对根目录扩容,需要对根目录进行在线扩容的请谨慎选择。
(如果有解决方法,欢迎留言。)
Linux实体机:
# qemu-img create -f qcow2 rhel-5.5-x86_64.qcow2 10G
# kvm -m 2048 -cdrom rhel-server-5.5-x86_64-dvd.iso -drive file=rhel-5.5-x86_64.qcow2,if=virtio,index=0 -boot d -net nic -net user
# kvm -m 2048 -drive file=rhel-5.5-x86_64.qcow2,if=virtio,index=0 -boot d -net nic -net user
- 1
- 2
- 3
- 1
- 2
- 3
此处,操作系统的安装与实体机安装一样,安装完成后会有一个1G左右的rhel-5.5-x86_64.qcow2文件。使用Virtual Machine Manager虚拟机管理工具从QCOW2文件启动虚拟机。
虚拟机:
# yum update -y
# chkconfig sshd on
# vim /etc/ssh/sshd_config
--- #PermitEmptyPasswords no
+++ PasswordAuthentication yes
--- #PermitRootLogin yes
+++ PermitRootLogin yes
# yum install acpid
# chkconfig acpid on
# yum install cloud-init
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
/etc/cloud/cloud-init.conf可能需要进行适当修改。
- 为保证实例能够访问neutron metadata服务,需要禁用zeroconf
# echo "NOZEROCONF=yes" >> /etc/sysconfig/network
- 1
- 1
- 开启磁盘热插拔,支持在线挂载云硬盘
#echo -e "#! /bin/sh
/sbin/modinfo -F filename acpiphp > /dev/null 2>&1
if [ $? -eq 0 ]; then
/sbin/modprobe acpiphp
fi" >> /etc/sysconfig/modules/acpiphp.modules
- 1
- 1
- 开启nova console log支持
# vim /boot/grub/menu.lst
+++ serial --unit=0 --speed=115200
+++ terminal --timeout=10 console serial
--- kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/VolGroup00/LogVol00
+++ kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/VolGroup00/LogVol00 console=tty0 console=ttyS0,115200n8
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 制作完成,关闭虚拟机
#/sbin/shutdown -h now
- 1
- 1
Linux实体机:
- 清理虚拟机登陆及日志信息等
# virt-sysprep -d rhel5.5
- 1
- 1
- 压缩镜像文件
# qemu-img convert -c -O qcow2 /root/rhel-5.5-x86_64.qcow2 /root/rhel-5.5-x86_64-compressed.qcow2
- 1
- 1
- 上传镜像
# glance image-create --name "RedHat Enterprise Linux 5.5 x86_64" --disk-format qcow2 --container-format bare --is-public True --file /root/rhel-5.5-x86_64-compressed.qcow2 --progress
- 1
- 1
Q&A
a. Cannot see the attached volume in the instance:
For RHEL 5.x, acpiphp is not loaded.
# modprobe acpiphp
# reboot
- 1
- 2
- 1
- 2
***Bootable kernel module hotplugin and acpiphp should be added.