OpenStack CentOS-6.5鏡像建立

來源:互聯網
上載者:User

標籤:openstack centos-6.5 鏡像

before.安裝軟體

yum install libvirt libguestfs-tools qemu-kvm qemu-imgyum groupinstall Virtualization "Virtualization Client" -yyum -y install libvirt libguestfs-tools -y


1.下載一個最小的centos6.5的iso檔案

wget http://mirrors.163.com/centos/6.5/isos/x86_64/CentOS-6.5-x86_64-minimal.iso

2.建立一個空的鏡像檔案

qemu-img create -f qcow2 /tmp/CentOS6.5-working.qcow2 10G

3.建立虛擬機器

qemu-img create -f qcow2 /tmp/CentOS6.5-working.qcow2 10G virt-install --virt-type=kvm --name=CentOS6.5 --ram=1024 --cdrom=/tmp/CentOS-6.5-x86_64-minimal.iso --disk=/tmp/CentOS6.5-working.qcow2,format=qcow2 --graphics=vnc,listen=0.0.0.0 --noautoconsole --os-type=linux --os-variant=rhel6

4.vnc遠程安裝,地址連接埠5900;分區只分一個,掛載到“/”,格式為ext4;

#重啟後執行命令開啟虛擬機器virsh start centos6.5

5.初始化

#!/bin/bash# add the EPEL repo and updaterpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm#yum -y update# install cloud-inityum -y install cloud-utils cloud-init parted git acpidchkconfig acpid on # install linux rootfs resizecd /tmpgit clone https://github.com/flegmatik/linux-rootfs-resize.gitcd linux-rootfs-resize./installif [[ $? -eq 0 ]];then  cd /tmp  rm -rf linux-rootfs-resizeelse  exitfi #change sshd portsed -i ‘s/^#Port 22/Port 65530/g‘ /etc/ssh/sshd_config# clean up the network interface stuffrm /etc/udev/rules.d/70-persistent-net.rulessed -i ‘/HWADDR/d‘ /etc/sysconfig/network-scripts/ifcfg-eth0sed -i ‘/UUID/d‘ /etc/sysconfig/network-scripts/ifcfg-eth0sed -i ‘/^ONBOOT/ s/no/yes/g‘ /etc/sysconfig/network-scripts/ifcfg-eth0sed -i ‘/^NM_CONTROLLED/ s/yes/no/g‘ /etc/sysconfig/network-scripts/ifcfg-eth0echo "NOZEROCONF=yes" >> /etc/sysconfig/network# graft up grubsed -i ‘s/timeout=5/timeout=0/g‘ /boot/grub/menu.lstsed -i ‘/^\skernel/ s/$/ console=tty0 console=ttyS0,115200n8/‘ /boot/grub/menu.lst# say something cute in /etc/motdecho "This is Openstack-CentOS-6" >> /etc/motd# notify we‘re haltingecho "Halting instance in 5 seconds!"sleep 5# halt the instancehalt

6.善後操作

#清除網路相關硬體產生資訊virt-sysprep -d centos6.5#壓縮鏡像virt-sparsify --compress /tmp/CentOS6.5-working.qcow2 CentOS6.5-working_1.qcow2

7.完成

本文出自 “8446082” 部落格,請務必保留此出處http://8456082.blog.51cto.com/8446082/1698680

OpenStack CentOS-6.5鏡像建立

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.