This is the next installment in the never-ending series of OpenStack image builds. Today's target: CentOS
Image Characteristics
The usual suspects are present:
- minimal package install
- serial console support
- timezone is Etc/UTC
- hostname set to instance name
- a single partition with root filesystem, no swap
- grow root filesystem to device size
- enable EPEL (install epel-release)
- enable could-init repo to get 0.7.1
A few things are still lacking:
- selinux is in permissive mode, make enforcing
- strengthen default firewall
Build
Tools like Oz are a good idea in theory but in practice seem to be quite picky about the environment they will correctly run on. I'm looking at you libguestfs. Other tools like the venerable appliance-creator get hung up on needing the same version of things in the host as in the chroot.
Good ole virt-install happily runs on damn near everything. This build has been tested on CentOS 6.4 and Ubuntu 12.10. TODO(dtroyer): don't run this all as root
Let's get started.
Install virt-install and all its prerequisites
on Ubuntu:
sudo apt-get install virtinst
on CentOS:
sudo yum install libvirt python-virtinst qemu-kvm sudo /etc/init.d/libvirtd start
Get a CentOS 6 kickstart file with minimal stuff and the extras that we need. Included in %post is a bit to resize the root filesystem to the size of the actual device provided to the VM.
Create base image with virt-install:
sudo virt-install \ --name centos-6-x86_64 \ --ram 1024 \ --cpu host \ --vcpus 1 \ --nographics \ --os-type=linux \ --os-variant=rhel6 \ --location=http://mirrors.kernel.org/centos/6/os/x86_64 \ --initrd-inject=centos-6-x86_64.ks \ --extra-args="ks=file:/centos-6-x86_64.ks text console=tty0 utf8 console=ttyS0,115200" \ --disk path=/var/lib/libvirt/images/centos-6-x86_64.img,size=2,bus=virtio \ --force \ --noreboot
Point to the bridge with external connectivity if it is not eth0:
--network=bridge=br0
If libguestfs is functional on your build platform:
sudo yum install -y libguestfs-tools sudo virt-sysprep --no-selinux-relabel -a /var/lib/libvirt/images/centos-6-x86_64.img sudo virt-sparsify --convert qcow2 --compress /var/lib/libvirt/images/centos-6-x86_64.img centos-6-x86_64.qcow2
Kick it into the cloud image repository:
glance image-create --name "CentOS 6 x86_64" \ --disk-format qcow2 --container-format bare \ --is-public false --file centos-6-x86_64.qcow2
출처 : http://hackstack.org/x/blog/2013/04/25/a-centos-6-image-for-openstack/
http://openstack.redhat.com/Creating_CentOS_and_Fedora_images_ready_for_Openstack
'Legacy Skills > VM' 카테고리의 다른 글
프록시를 통해 Docker 컨테이너 로그를 CloudWatch Logs에 푸시하려면 어떻게 해야 합니까? (0) | 2019.12.18 |
---|---|
Build vlan header in c (0) | 2014.07.31 |
VLAN Tagging (0) | 2014.07.30 |
Linux KVM: disable/enable virbr0 NAT Interface (0) | 2014.07.24 |
How to install Open vSwitch and test connection of VMs over GRE (0) | 2014.07.14 |
댓글