制作centos6.5 镜像,安装cloud-init 支持openstack 密码注入
2016-05-11 13:43
621 查看
Centos7 直接yum安装cloud-init 即可
Steps to create a CentOS image
Use virt-manager to install CentOS with a small disk (I used one of 10 GB) and do aminimal install, make special note of the name as it will be used later, for this guide the name chosen iscentos-6.5. Also, during installationyou need to create only one partition for / in ext4 format (this means, no lvm, no swap, etc.)
Alternatively you could do something like:
$ qemu-img create -f qcow2 /tmp/centos-6.5-working.qcow2 10G $ virt-install --virt-type kvm --name centos-6.5 --ram 1024 \ --cdrom=/tmp/CentOS-6.5-x86_64-minimal.iso \ --disk /tmp/centos-6.5-working.qcow2,format=qcow2 \ --network network=default \ --graphics vnc,listen=0.0.0.0 --noautoconsole \ --os-type=linux --os-variant=rhel6
After install, reboot the vm and log in as root.
Modify /etc/sysconfig/network-scripts/ifcfg-eth0 so it looks like the following (the important bits are: no mac defined and bootproto dhcp):
TYPE=Ethernet DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp NM_CONTROLLED=no
Install the EPEL repository
$ yum install -y http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Update the system
$ yum -y distro-sync
Install cloud-init packages and git (this one is required to install linux rootfs resize)
yum install -y cloud-utils cloud-init parted git
Install linux rootfs resize
cd /tmp git clone https://github.com/flegmatik/linux-rootfs-resize.git cd linux-rootfs-resize ./install
Edit /etc/cloud/cloud.cfg and under cloud_init_modules add:
- resolv-conf
Add the following line to /etc/sysconfig/network (this is to avoid problems accessing the EC2 metadata service)
NOZEROCONF=yes
Poweroff the vm
$ poweroff
Reset and clean the image so it can be reused without issues
$ virt-sysprep -d centos-6.5
Reduce image size by zero-in unused blocks in the virtual disk (Run as root to avoid issues changing selinux context on the final step)
$ virt-sparsify --compress /tmp/centos-6.5-working.qcow2 centos-6.5-cloud.qcow2
You're done!
The image centos-6.5-cloud.qcow2 is ready to be uploaded to Openstack.
相关文章推荐
- Centos6 编译安装Python
- 硬盘安装CentOS 6.2以及添加GRUB启动菜单
- CentOS 6.2实战部署Nginx+MySQL+PHP
- CentOS 7系统配置上的变化解析
- CentOS下DB2数据库安装过程详解
- 什么是OpenStack 开源的云计算管理平台项目
- CentOS 6.3下编译安装Ruby 2.0笔记
- 在Centos 5.5 上编译安装mysql 5.5.9
- 在阿里云的CentOS环境中安装配置MySQL的教程
- CentOS 6.5源码安装Erlang教程
- Centos下安装docker教程
- 在CenOS系统下安装和配置Redis数据库的教程
- centos 5.6 升级php到5.3的方法
- CentOS mysql安装系统方法
- centos下安装mysql服务器的方法
- CentOS 5.1 4.6最新官方下载地址列表
- Centos搭建GTK+Codeblock完整版
- CentOS 5.1下跑Mono和Asp.net的实现方法