Create a centos6.5 image for openstack

Source: Internet
Author: User

Purpose:

Create a centos6.5 KVM image in the centos6.5 operating system environment and install cloud-init to automatically expand the root partition.


I. Production Environment:

Operating environment is to open an instance in the openstack platform, installed centos6.5, image from: http://cloud.centos.org/centos/6.5/images/CentOS-6-x86_64-GenericCloud-20140929_01.qcow2

The image created by the centos community does not support automatic expansion of the root partition. As a result, no matter how large the disk size you specify when creating an instance, it is more than 7 GB.


Ii. Install software:

Yum groupinstall virtualization "virtualization client" yum install libvirt
Iii. Production Process:
1. Download the smallest centos6.5 ISO file: wgethttp: // mirrors.163.com/centos/6.5/isos/x86_64/centos-6.5-x86_64-minimal.iso
2. Create an empty image file:
qemu-img create -f qcow2 centos-6.5.qcow2 5G
 
3. Create a command:
virt-install  --name centos-6.5 --ram 1024 --cdrom=CentOS-6.5-x86_64-minimal.iso --disk centos-6.5.qcow2,format=qcow2 --graphics vnc,listen=0.0.0.0 —noautoconsole --os-type=linux --os-variant=rhel6
4. system installation process: the partition is only divided into one partition, mounted to "/", in the format of ext4; Do not partition swap, Boot, etc. 5. initialize the image: (1) After the system is installed, click restart, in fact, in the virsh command to see this virtual machine, has been shut down, to use the command to start it virsh start centos-6.5 note: the startup process is very slow, can only wait, do not restart it at startup. Otherwise, the problem may occur. (2) connect through VNC-viewer. If you have run multiple virtual machines, you can use the following command to view the virtual machine's VNC port virsh vncdisplay centos-6.5 (3) to enable the Nova console-log to output the instance startup process to the instance startup log 
/boot/grub/menu.lstAdd the following content to the kernel parameter: 
Kernel... (N parameters are omitted )...Console = tty0 console = ttys0, 115200n8
(4) modify the network information/etc/sysconfig/network-scripts/ifcfg-eth0 (delete Mac information) as follows:
TYPE=EthernetDEVICE=eth0ONBOOT=yesBOOTPROTO=dhcpNM_CONTROLLED=no
Add a line to/etc/sysconfig/network:
NOZERCONF=yes
(5) Add the epel source, update the system, and install git:
yum install -y http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum -y distro-sync
yum -y git
(6) install the ACPI service so that the host machine can perform power management operations such as on/off on the VM.
yum install acpid
chkconfig acpid on
(7) install linux rootfs resize so that the root partition can be automatically expanded when the instance is started.
cd /tmpgit clone https://github.com/flegmatik/linux-rootfs-resize.gitcd linux-rootfs-resize./install
(8) install cloud-init
yum install -y cloud-utils cloud-init parted
Modify the configuration file/etc/cloud. cfg and add it under cloud_init_modules:
 - resolv-conf
(9) shutdown:
poweroff
6. aftercare operations
(1) Clear network-related hardware generation information
virt-sysprep -d centos-6.5
(2) compressing an image
virt-sparsify --compress /tmp/centos-6.5.qcow2 centos-6.5-cloud.qcow2
Image Creation ends here

Reference: http://docs.openstack.org/image-guide/content/centos-image.html#d6e899https://openstack.redhat.com/Creating_CentOS_and_Fedora_images_ready_for_Openstack

Create a centos6.5 image for openstack

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.